Merge remote-tracking branch 'origin/dev' into satoken
# Conflicts:
# pom.xml
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
# ruoyi-common/pom.xml
# ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
# ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
# ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
# ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java
# ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TokenServiceImpl.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserDetailsServiceImpl.java
已修改158个文件
已添加17个文件
已删除2个文件
| | |
| | | []() |
| | | []() |
| | | []() |
| | | []() |
| | | |
| | | > RuoYi-Vue-Plus æ¯åºäº RuoYi-Vue é对 `åå¸å¼é群` åºæ¯å级(ä¸å
¼å®¹åæ¡æ¶) |
| | | > RuoYi-Vue-Plus æ¯éå RuoYi-Vue é对 `åå¸å¼é群` åºæ¯å
¨æ¹ä½å级(ä¸å
¼å®¹åæ¡æ¶) |
| | | |
| | | > ç³»ç»æ¼ç¤º: [ä¼ éé¨](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/ç³»ç»æ¼ç¤º?sort_id=4836388) |
| | | |
| | | | åè½ä»ç» | ä½¿ç¨ææ¯ | ææ¡£å°å | ç¹æ§æ³¨æäºé¡¹ | |
| | | |---|---|---|---| |
| | | | å½åæ¡æ¶ | RuoYi-Vue-Plus | [RuoYi-Vue-Plusææ¡£](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) | éåRuoYi-Vueå
¨æ¹ä½å级(ä¸å
¼å®¹åæ¡æ¶) | |
| | | | satoken忝 | RuoYi-Vue-Plus-satoken | [satoken忝å°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 使ç¨satokenéææéé´æ(å
¬æµ å¯å°è¯ä¸ç产) | |
| | | | satoken忝 | RuoYi-Vue-Plus-satoken | [satoken忝å°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | é«å¯è¯»æ§ æ©å±æ§(æ¨è使ç¨) | |
| | | | åä½åæ¯ | RuoYi-Vue-Plus-fast | [fast忝å°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) | åä½åºç¨ç»æ | |
| | | | Vue3忝 | RuoYi-Vue-Plus-UI | [UIå°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus-UI) | ç±äºç»ä»¶è¿æªå®å ä»
ä¾å¦ä¹ | |
| | | | åæ¡æ¶ | RuoYi-Vue | [RuoYi-Vueå®ç½](http://ruoyi.vip/) | 宿忥éè¦çåè½ | |
| | | | å端å¼åæ¡æ¶ | VueãElement UI | [Element UIå®ç½](https://element.eleme.cn/#/zh-CN) | | |
| | | | å端å¼åæ¡æ¶ | SpringBoot | [SpringBootå®ç½](https://spring.io/projects/spring-boot/#learn) | | |
| | | | 容卿¡æ¶ | Undertow | [Undertowå®ç½](https://undertow.io/) | åºäº Netty ç髿§è½å®¹å¨ | |
| | | | 容卿¡æ¶ | Undertow | [Undertowå®ç½](https://undertow.io/) | åºäº XNIO ç髿§è½å®¹å¨ | |
| | | | æéè®¤è¯æ¡æ¶ | Spring SecurityãJwt | [SpringSecurityå®ç½](https://spring.io/projects/spring-security#learn) | æ¯æå¤ç»ç«¯è®¤è¯ç³»ç» | |
| | | | å
³ç³»æ°æ®åº | MySQL | [MySQLå®ç½](https://dev.mysql.com/) | éé
8.X æä½ 5.7 | |
| | | | ç¼åæ°æ®åº | Redis | [Rediså®ç½](https://redis.io/) | éé
6.X æä½ 4.X | |
| | |
| | | |
| | | <properties> |
| | | <ruoyi-vue-plus.version>3.4.0</ruoyi-vue-plus.version> |
| | | <spring-boot.version>2.5.7</spring-boot.version> |
| | | <spring-boot.version>2.5.8</spring-boot.version> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| | | <java.version>1.8</java.version> |
| | |
| | | <swagger-annotations.version>1.5.22</swagger-annotations.version> |
| | | <poi.version>4.1.2</poi.version> |
| | | <easyexcel.version>2.2.11</easyexcel.version> |
| | | <cglib.version>3.3.0</cglib.version> |
| | | <velocity.version>2.3</velocity.version> |
| | | <satoken.version>1.28.0</satoken.version> |
| | | <mybatis-plus.version>3.4.3.4</mybatis-plus.version> |
| | | <p6spy.version>3.9.1</p6spy.version> |
| | | <hutool.version>5.7.16</hutool.version> |
| | | <hutool.version>5.7.17</hutool.version> |
| | | <okhttp.version>4.9.2</okhttp.version> |
| | | <spring-boot-admin.version>2.5.4</spring-boot-admin.version> |
| | | <redisson.version>3.16.4</redisson.version> |
| | | <spring-boot-admin.version>2.5.5</spring-boot-admin.version> |
| | | <redisson.version>3.16.6</redisson.version> |
| | | <lock4j.version>2.2.1</lock4j.version> |
| | | <dynamic-ds.version>3.4.1</dynamic-ds.version> |
| | | <tlog.version>1.3.4</tlog.version> |
| | | <dynamic-ds.version>3.5.0</dynamic-ds.version> |
| | | <tlog.version>1.3.6</tlog.version> |
| | | <xxl-job.version>2.3.0</xxl-job.version> |
| | | |
| | | <!-- jdk11 缺失ä¾èµ jaxb--> |
| | | <jaxb.version>3.0.1</jaxb.version> |
| | | |
| | | <!-- OSS é
ç½® --> |
| | | <qiniu.version>7.8.0</qiniu.version> |
| | | <qiniu.version>7.9.0</qiniu.version> |
| | | <aliyun.oss.version>3.13.1</aliyun.oss.version> |
| | | <qcloud.cos.version>5.6.58</qcloud.cos.version> |
| | | <minio.version>8.3.3</minio.version> |
| | | <minio.version>8.3.4</minio.version> |
| | | |
| | | <!-- docker é
ç½® --> |
| | | <docker.registry.url>localhost</docker.registry.url> |
| | |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cglib</groupId> |
| | | <artifactId>cglib</artifactId> |
| | | <version>${cglib.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- velocity代ç çæä½¿ç¨æ¨¡æ¿ --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <artifactId>hutool-core</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-http</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-captcha</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-extra</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-jwt</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-spring-boot-configuration</artifactId> |
| | | <artifactId>tlog-web-spring-boot-starter</artifactId> |
| | | <version>${tlog.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-webroot</artifactId> |
| | | <version>${tlog.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>javassist</artifactId> |
| | | <groupId>org.javassist</groupId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <artifactId>guava</artifactId> |
| | | <groupId>com.google.guava</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-xxl-job</artifactId> |
| | | <artifactId>tlog-xxljob-spring-boot-starter</artifactId> |
| | | <version>${tlog.version}</version> |
| | | </dependency> |
| | | |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | @ApiOperation("æ¥è¯¢ç³»ç»è®¿é®è®°å½å表") |
| | | @SaCheckPermission("monitor:logininfor:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor) { |
| | | return logininforService.selectPageLogininforList(logininfor); |
| | | public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) { |
| | | return logininforService.selectPageLogininforList(logininfor, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºç³»ç»è®¿é®è®°å½å表") |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | @ApiOperation("æ¥è¯¢æä½æ¥å¿è®°å½å表") |
| | | @SaCheckPermission("monitor:operlog:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOperLog> list(SysOperLog operLog) { |
| | | return operLogService.selectPageOperLogList(operLog); |
| | | public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) { |
| | | return operLogService.selectPageOperLogList(operLog, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("å¯¼åºæä½æ¥å¿è®°å½å表") |
| | |
| | | import com.ruoyi.common.core.domain.dto.UserOnlineDTO; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysUserOnline; |
| | |
| | | Collections.reverse(userOnlineDTOList); |
| | | userOnlineDTOList.removeAll(Collections.singleton(null)); |
| | | List<SysUserOnline> userOnlineList = BeanUtil.copyToList(userOnlineDTOList, SysUserOnline.class); |
| | | return PageUtils.buildDataInfo(userOnlineList); |
| | | return TableDataInfo.build(userOnlineList); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | @ApiOperation("è·ååæ°é
ç½®å表") |
| | | @SaCheckPermission("system:config:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysConfig> list(SysConfig config) { |
| | | return configService.selectPageConfigList(config); |
| | | public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) { |
| | | return configService.selectPageConfigList(config, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºåæ°é
ç½®å表") |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("æ¥è¯¢åå
¸æ°æ®å表") |
| | | @SaCheckPermission("system:dict:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysDictData> list(SysDictData dictData) { |
| | | return dictDataService.selectPageDictDataList(dictData); |
| | | public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) { |
| | | return dictDataService.selectPageDictDataList(dictData, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºåå
¸æ°æ®å表") |
| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("æ¥è¯¢åå
¸ç±»åå表") |
| | | @SaCheckPermission("system:dict:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysDictType> list(SysDictType dictType) { |
| | | return dictTypeService.selectPageDictTypeList(dictType); |
| | | public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) { |
| | | return dictTypeService.selectPageDictTypeList(dictType, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºåå
¸ç±»åå表") |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | |
| | | @ApiOperation("è·åéç¥å
¬åå表") |
| | | @SaCheckPermission("system:notice:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysNotice> list(SysNotice notice) { |
| | | return noticeService.selectPageNoticeList(notice); |
| | | public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) { |
| | | return noticeService.selectPageNoticeList(notice, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | |
| | | @ApiOperation("æ¥è¯¢å¯¹è±¡åå¨é
ç½®å表") |
| | | @SaCheckPermission("system:oss:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo) { |
| | | return iSysOssConfigService.queryPageList(bo); |
| | | public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageQuery pageQuery) { |
| | | return iSysOssConfigService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("æ¥è¯¢OSS对象åå¨å表") |
| | | @SaCheckPermission("system:oss:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo) { |
| | | return iSysOssService.queryPageList(bo); |
| | | public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) { |
| | | return iSysOssService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | @ApiOperation("è·åå²ä½å表") |
| | | @SaCheckPermission("system:post:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysPost> list(SysPost post) { |
| | | return postService.selectPagePostList(post); |
| | | public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) { |
| | | return postService.selectPagePostList(post, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºå²ä½å表") |
| | |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | |
| | | @ApiOperation("æ¥è¯¢è§è²ä¿¡æ¯å表") |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysRole> list(SysRole role) { |
| | | return roleService.selectPageRoleList(role); |
| | | public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) { |
| | | return roleService.selectPageRoleList(role, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºè§è²ä¿¡æ¯å表") |
| | |
| | | @ApiOperation("æ¥è¯¢å·²åé
ç¨æ·è§è²å表") |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo<SysUser> allocatedList(SysUser user) { |
| | | return userService.selectAllocatedList(user); |
| | | public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) { |
| | | return userService.selectAllocatedList(user, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ¥è¯¢æªåé
ç¨æ·è§è²å表") |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo<SysUser> unallocatedList(SysUser user) { |
| | | return userService.selectUnallocatedList(user); |
| | | public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) { |
| | | return userService.selectUnallocatedList(user, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | @ApiOperation("è·åç¨æ·å表") |
| | | @SaCheckPermission("system:user:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysUser> list(SysUser user) { |
| | | return userService.selectPageUserList(user); |
| | | public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) { |
| | | return userService.selectPageUserList(user, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导åºç¨æ·å表") |
| | |
| | | # ä¸»åºæ°æ®æº |
| | | master: |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true |
| | | # jdbc ææåæ°é
ç½®åè https://lionli.blog.csdn.net/article/details/122018562 |
| | | # rewriteBatchedStatements=true æ¹å¤çä¼å 大å¹
æåæ¹éæå
¥æ´æ°å 餿§è½(å¯¹æ°æ®åºææ§è½æè ä½¿ç¨æ¹éæä½åºèèæ§è½é®é¢) |
| | | url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true |
| | | username: root |
| | | password: root |
| | | # ä»åºæ°æ®æº |
| | |
| | | # ä¸»åºæ°æ®æº |
| | | master: |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://172.30.0.36:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true |
| | | # jdbc ææåæ°é
ç½®åè https://lionli.blog.csdn.net/article/details/122018562 |
| | | # rewriteBatchedStatements=true æ¹å¤çä¼å 大å¹
æåæ¹éæå
¥æ´æ°å 餿§è½(å¯¹æ°æ®åºææ§è½æè ä½¿ç¨æ¹éæä½åºèèæ§è½é®é¢) |
| | | url: jdbc:mysql://172.30.0.36:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true |
| | | username: root |
| | | password: root |
| | | # ä»åºæ°æ®æº |
| | |
| | | # è·åipå°åå¼å
³ |
| | | addressEnabled: true |
| | | # ç¼åæå è½½ |
| | | cacheLazy: true |
| | | cacheLazy: false |
| | | |
| | | captcha: |
| | | # é¡µé¢ <åæ°è®¾ç½®> å¯å¼å¯å
³é éªè¯ç æ ¡éª |
| | |
| | | com.ruoyi: @logging.level@ |
| | | org.springframework: warn |
| | | config: classpath:logback.xml |
| | | |
| | | # tlog å
¨å±è®¿é®æ§è½æ¦æª |
| | | tlog: |
| | | enable-invoke-time-print: true |
| | | |
| | | # Springé
ç½® |
| | | spring: |
| | |
| | | - /*/api-docs |
| | | # druid çæ§é
ç½® |
| | | - /druid/** |
| | | # ç¨æ·æ¾è¡ |
| | | permit-all: |
| | | # actuator çæ§é
ç½® |
| | | - /actuator |
| | | - /actuator/** |
| | |
| | | not.null=* å¿
须填å |
| | | user.jcaptcha.error=éªè¯ç é误 |
| | | user.jcaptcha.expire=éªè¯ç 已失æ |
| | | user.not.exists=ç¨æ·ä¸åå¨/å¯ç é误 |
| | | user.not.exists=对ä¸èµ·, æ¨çè´¦å·ï¼{0} ä¸åå¨. |
| | | user.password.not.match=ç¨æ·ä¸åå¨/å¯ç é误 |
| | | user.password.retry.limit.count=å¯ç è¾å
¥é误{0}次 |
| | | user.password.retry.limit.exceed=å¯ç è¾å
¥é误{0}次ï¼å¸æ·éå®10åé |
| | | user.password.delete=对ä¸èµ·ï¼æ¨çè´¦å·å·²è¢«å é¤ |
| | | user.blocked=ç¨æ·å·²å°ç¦ï¼è¯·è系管çå |
| | | user.password.retry.limit.exceed=å¯ç é误次æ°è¿å¤ï¼å¸æ·éå®{0}åé |
| | | user.password.delete=对ä¸èµ·ï¼æ¨çè´¦å·ï¼{0} 已被å é¤ |
| | | user.blocked=对ä¸èµ·ï¼æ¨çè´¦å·ï¼{0} å·²ç¦ç¨ï¼è¯·è系管çå |
| | | role.blocked=è§è²å·²å°ç¦ï¼è¯·è系管çå |
| | | user.logout.success=éåºæå |
| | | length.not.valid=é¿åº¦å¿
é¡»å¨{min}å°{max}个å符ä¹é´ |
| | |
| | | not.null=* Required fill in |
| | | user.jcaptcha.error=Captcha error |
| | | user.jcaptcha.expire=Captcha invalid |
| | | user.not.exists=User does not exist/Password error |
| | | user.not.exists=Sorry, your account: {0} does not exist |
| | | user.password.not.match=User does not exist/Password error |
| | | user.password.retry.limit.count=Password input error {0} times |
| | | user.password.retry.limit.exceed=Password input error {0} times, account locked for 10 minutes |
| | | user.password.delete=Sorry, your account has been deleted |
| | | user.blocked=User disabledï¼please contact administrators |
| | | user.password.retry.limit.exceed=Too many password errors, account locked for {0} minutes |
| | | user.password.delete=Sorry, your accountï¼{0} has been deleted |
| | | user.blocked=Sorry, your account: {0} has been disabled. Please contact the administrator |
| | | role.blocked=Role disabledï¼please contact administrators |
| | | user.logout.success=Exit successful |
| | | length.not.valid=The length must be between {min} and {max} characters |
| | |
| | | not.null=* å¿
须填å |
| | | user.jcaptcha.error=éªè¯ç é误 |
| | | user.jcaptcha.expire=éªè¯ç 已失æ |
| | | user.not.exists=ç¨æ·ä¸åå¨/å¯ç é误 |
| | | user.not.exists=对ä¸èµ·, æ¨çè´¦å·ï¼{0} ä¸åå¨. |
| | | user.password.not.match=ç¨æ·ä¸åå¨/å¯ç é误 |
| | | user.password.retry.limit.count=å¯ç è¾å
¥é误{0}次 |
| | | user.password.retry.limit.exceed=å¯ç è¾å
¥é误{0}次ï¼å¸æ·éå®10åé |
| | | user.password.delete=对ä¸èµ·ï¼æ¨çè´¦å·å·²è¢«å é¤ |
| | | user.blocked=ç¨æ·å·²å°ç¦ï¼è¯·è系管çå |
| | | user.password.retry.limit.exceed=å¯ç é误次æ°è¿å¤ï¼å¸æ·éå®{0}åé |
| | | user.password.delete=对ä¸èµ·ï¼æ¨çè´¦å·ï¼{0} 已被å é¤ |
| | | user.blocked=对ä¸èµ·ï¼æ¨çè´¦å·ï¼{0} å·²ç¦ç¨ï¼è¯·è系管çå |
| | | role.blocked=è§è²å·²å°ç¦ï¼è¯·è系管çå |
| | | user.logout.success=éåºæå |
| | | length.not.valid=é¿åº¦å¿
é¡»å¨{min}å°{max}个å符ä¹é´ |
| | |
| | | <artifactId>easyexcel</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cglib</groupId> |
| | | <artifactId>cglib</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- ymlè§£æå¨ --> |
| | | <dependency> |
| | | <groupId>org.yaml</groupId> |
| | | <artifactId>snakeyaml</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- <!–Tokençæä¸è§£æ–>--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>io.jsonwebtoken</groupId>--> |
| | | <!-- <artifactId>jjwt</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- jdk11 缺失ä¾èµ jaxb--> |
| | | <dependency> |
| | |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-extension</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- dynamic-datasource 夿°æ®æº--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-client</artifactId> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-core</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-http</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-captcha</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-jwt</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-extra</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <artifactId>swagger-annotations</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-actuator</artifactId> |
| | | </dependency> |
| | | <!-- èªå¨çæYMLé
ç½®å
³èJSONæä»¶ --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>lock4j-redisson-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-spring-boot-configuration</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-webroot</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * æ°æ®æé |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.5.0 |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface DataColumn { |
| | | |
| | | /** |
| | | * å ä½ç¬¦å
³é®å |
| | | */ |
| | | String key() default "deptName"; |
| | | |
| | | /** |
| | | * å ä½ç¬¦æ¿æ¢å¼ |
| | | */ |
| | | String value() default "dept_id"; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * æ°æ®æéç» |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.5.0 |
| | | */ |
| | | @Target({ElementType.METHOD, ElementType.TYPE}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface DataPermission { |
| | | |
| | | DataColumn[] value(); |
| | | |
| | | } |
| | |
| | | * æ°æ®æéè¿æ»¤æ³¨è§£ |
| | | * |
| | | * @author ruoyi |
| | | * @deprecated 3.6.0 ç§»é¤ {@link com.ruoyi.common.annotation.DataPermission} |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | @Deprecated |
| | | public @interface DataScope { |
| | | |
| | | /** |
| | | * é¨é¨è¡¨çå«å |
| | | */ |
| | |
| | | * æ¯å¦è¿æ»¤ç¨æ·æé |
| | | */ |
| | | boolean isUser() default false; |
| | | |
| | | } |
| | |
| | | * ä¼å
级ï¼å
æ¹æ³ï¼åç±»ï¼å¦ææ¹æ³è¦çäºç±»ä¸çæ°æ®æºç±»åï¼ä»¥æ¹æ³ç为åï¼å¦å以类ä¸ç为å |
| | | * |
| | | * @author ruoyi |
| | | * @deprecated 3.6.0 ç§»é¤ ä½¿ç¨åçæ³¨è§£å¤ç æ¹æ³æ´å
¨ {@link com.baomidou.dynamic.datasource.annotation.DS} |
| | | */ |
| | | @Target({ElementType.METHOD, ElementType.TYPE}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | @Inherited |
| | | @Deprecated |
| | | public @interface DataSource { |
| | | /** |
| | | * åæ¢æ°æ®æºåç§° |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Constants { |
| | | public interface Constants { |
| | | |
| | | /** |
| | | * UTF-8 å符é |
| | | */ |
| | | public static final String UTF8 = "UTF-8"; |
| | | String UTF8 = "UTF-8"; |
| | | |
| | | /** |
| | | * GBK å符é |
| | | */ |
| | | public static final String GBK = "GBK"; |
| | | String GBK = "GBK"; |
| | | |
| | | /** |
| | | * httpè¯·æ± |
| | | */ |
| | | public static final String HTTP = "http://"; |
| | | String HTTP = "http://"; |
| | | |
| | | /** |
| | | * httpsè¯·æ± |
| | | */ |
| | | public static final String HTTPS = "https://"; |
| | | String HTTPS = "https://"; |
| | | |
| | | /** |
| | | * éç¨æåæ è¯ |
| | | */ |
| | | public static final String SUCCESS = "0"; |
| | | String SUCCESS = "0"; |
| | | |
| | | /** |
| | | * éç¨å¤±è´¥æ è¯ |
| | | */ |
| | | public static final String FAIL = "1"; |
| | | String FAIL = "1"; |
| | | |
| | | /** |
| | | * ç»å½æå |
| | | */ |
| | | public static final String LOGIN_SUCCESS = "Success"; |
| | | String LOGIN_SUCCESS = "Success"; |
| | | |
| | | /** |
| | | * 注é |
| | | */ |
| | | public static final String LOGOUT = "Logout"; |
| | | String LOGOUT = "Logout"; |
| | | |
| | | /** |
| | | * 注å |
| | | */ |
| | | public static final String REGISTER = "Register"; |
| | | String REGISTER = "Register"; |
| | | |
| | | /** |
| | | * ç»å½å¤±è´¥ |
| | | */ |
| | | public static final String LOGIN_FAIL = "Error"; |
| | | String LOGIN_FAIL = "Error"; |
| | | |
| | | /** |
| | | * éªè¯ç redis key |
| | | */ |
| | | public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; |
| | | String CAPTCHA_CODE_KEY = "captcha_codes:"; |
| | | |
| | | /** |
| | | * ç»å½ç¨æ· redis key |
| | |
| | | /** |
| | | * é²éæäº¤ redis key |
| | | */ |
| | | public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; |
| | | String REPEAT_SUBMIT_KEY = "repeat_submit:"; |
| | | |
| | | /** |
| | | * éæµ redis key |
| | | */ |
| | | public static final String RATE_LIMIT_KEY = "rate_limit:"; |
| | | String RATE_LIMIT_KEY = "rate_limit:"; |
| | | |
| | | /** |
| | | * éªè¯ç æææï¼åéï¼ |
| | | */ |
| | | public static final Integer CAPTCHA_EXPIRATION = 2; |
| | | Integer CAPTCHA_EXPIRATION = 2; |
| | | |
| | | /** |
| | | * ç»éé误 redis key |
| | | */ |
| | | String LOGIN_ERROR = "login_error:"; |
| | | |
| | | /** |
| | | * ç»å½éè¯¯æ¬¡æ° |
| | | */ |
| | | Integer LOGIN_ERROR_NUMBER = 5; |
| | | |
| | | /** |
| | | * ç»å½é误éå¶æ¶é´(åé) |
| | | */ |
| | | Integer LOGIN_ERROR_LIMIT_TIME = 10; |
| | | |
| | | /** |
| | | * 令ç |
| | | */ |
| | | public static final String TOKEN = "token"; |
| | | String TOKEN = "token"; |
| | | |
| | | /** |
| | | * 令çåç¼ |
| | | */ |
| | | public static final String LOGIN_USER_KEY = "login_user_key"; |
| | | String LOGIN_USER_KEY = "login_user_key"; |
| | | |
| | | /** |
| | | * åæ°ç®¡ç cache key |
| | | */ |
| | | public static final String SYS_CONFIG_KEY = "sys_config:"; |
| | | String SYS_CONFIG_KEY = "sys_config:"; |
| | | |
| | | /** |
| | | * åå
¸ç®¡ç cache key |
| | | */ |
| | | public static final String SYS_DICT_KEY = "sys_dict:"; |
| | | String SYS_DICT_KEY = "sys_dict:"; |
| | | |
| | | } |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class GenConstants { |
| | | public interface GenConstants { |
| | | /** |
| | | * å表ï¼å¢å æ¹æ¥ï¼ |
| | | */ |
| | | public static final String TPL_CRUD = "crud"; |
| | | String TPL_CRUD = "crud"; |
| | | |
| | | /** |
| | | * æ 表ï¼å¢å æ¹æ¥ï¼ |
| | | */ |
| | | public static final String TPL_TREE = "tree"; |
| | | String TPL_TREE = "tree"; |
| | | |
| | | /** |
| | | * 主å表ï¼å¢å æ¹æ¥ï¼ |
| | | */ |
| | | public static final String TPL_SUB = "sub"; |
| | | String TPL_SUB = "sub"; |
| | | |
| | | /** |
| | | * æ ç¼ç åæ®µ |
| | | */ |
| | | public static final String TREE_CODE = "treeCode"; |
| | | String TREE_CODE = "treeCode"; |
| | | |
| | | /** |
| | | * æ ç¶ç¼ç åæ®µ |
| | | */ |
| | | public static final String TREE_PARENT_CODE = "treeParentCode"; |
| | | String TREE_PARENT_CODE = "treeParentCode"; |
| | | |
| | | /** |
| | | * æ åç§°åæ®µ |
| | | */ |
| | | public static final String TREE_NAME = "treeName"; |
| | | String TREE_NAME = "treeName"; |
| | | |
| | | /** |
| | | * ä¸çº§èåIDåæ®µ |
| | | */ |
| | | public static final String PARENT_MENU_ID = "parentMenuId"; |
| | | String PARENT_MENU_ID = "parentMenuId"; |
| | | |
| | | /** |
| | | * ä¸çº§èååç§°åæ®µ |
| | | */ |
| | | public static final String PARENT_MENU_NAME = "parentMenuName"; |
| | | String PARENT_MENU_NAME = "parentMenuName"; |
| | | |
| | | /** |
| | | * æ°æ®åºå符串类å |
| | | */ |
| | | public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"}; |
| | | String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"}; |
| | | |
| | | /** |
| | | * æ°æ®åºææ¬ç±»å |
| | | */ |
| | | public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"}; |
| | | String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"}; |
| | | |
| | | /** |
| | | * æ°æ®åºæ¶é´ç±»å |
| | | */ |
| | | public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; |
| | | String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; |
| | | |
| | | /** |
| | | * æ°æ®åºæ°åç±»å |
| | | */ |
| | | public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", |
| | | "bit", "bigint", "float", "double", "decimal"}; |
| | | String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", |
| | | "bit", "bigint", "float", "double", "decimal"}; |
| | | |
| | | /** |
| | | * BO对象 ä¸éè¦æ·»å åæ®µ |
| | | */ |
| | | public static final String[] COLUMNNAME_NOT_ADD = {"create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version"}; |
| | | String[] COLUMNNAME_NOT_ADD = {"create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version"}; |
| | | |
| | | /** |
| | | * BO对象 ä¸éè¦ç¼è¾å段 |
| | | */ |
| | | public static final String[] COLUMNNAME_NOT_EDIT = {"create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version"}; |
| | | String[] COLUMNNAME_NOT_EDIT = {"create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version"}; |
| | | |
| | | /** |
| | | * VO对象 ä¸éè¦è¿ååæ®µ |
| | | */ |
| | | public static final String[] COLUMNNAME_NOT_LIST = {"create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version"}; |
| | | String[] COLUMNNAME_NOT_LIST = {"create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version"}; |
| | | |
| | | /** |
| | | * BO对象 ä¸éè¦æ¥è¯¢å段 |
| | | */ |
| | | public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "remark", "version"}; |
| | | String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "remark", "version"}; |
| | | |
| | | /** |
| | | * Entityåºç±»å段 |
| | | */ |
| | | public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime"}; |
| | | String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime"}; |
| | | |
| | | /** |
| | | * Treeåºç±»å段 |
| | | */ |
| | | public static final String[] TREE_ENTITY = {"parentName", "parentId", "children"}; |
| | | String[] TREE_ENTITY = {"parentName", "parentId", "children"}; |
| | | |
| | | /** |
| | | * ææ¬æ¡ |
| | | */ |
| | | public static final String HTML_INPUT = "input"; |
| | | String HTML_INPUT = "input"; |
| | | |
| | | /** |
| | | * ææ¬å |
| | | */ |
| | | public static final String HTML_TEXTAREA = "textarea"; |
| | | String HTML_TEXTAREA = "textarea"; |
| | | |
| | | /** |
| | | * ä¸ææ¡ |
| | | */ |
| | | public static final String HTML_SELECT = "select"; |
| | | String HTML_SELECT = "select"; |
| | | |
| | | /** |
| | | * åéæ¡ |
| | | */ |
| | | public static final String HTML_RADIO = "radio"; |
| | | String HTML_RADIO = "radio"; |
| | | |
| | | /** |
| | | * å¤éæ¡ |
| | | */ |
| | | public static final String HTML_CHECKBOX = "checkbox"; |
| | | String HTML_CHECKBOX = "checkbox"; |
| | | |
| | | /** |
| | | * æ¥ææ§ä»¶ |
| | | */ |
| | | public static final String HTML_DATETIME = "datetime"; |
| | | String HTML_DATETIME = "datetime"; |
| | | |
| | | /** |
| | | * å¾çä¸ä¼ æ§ä»¶ |
| | | */ |
| | | public static final String HTML_IMAGE_UPLOAD = "imageUpload"; |
| | | String HTML_IMAGE_UPLOAD = "imageUpload"; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ æ§ä»¶ |
| | | */ |
| | | public static final String HTML_FILE_UPLOAD = "fileUpload"; |
| | | String HTML_FILE_UPLOAD = "fileUpload"; |
| | | |
| | | /** |
| | | * å¯ææ¬æ§ä»¶ |
| | | */ |
| | | public static final String HTML_EDITOR = "editor"; |
| | | String HTML_EDITOR = "editor"; |
| | | |
| | | /** |
| | | * å符串类å |
| | | */ |
| | | public static final String TYPE_STRING = "String"; |
| | | String TYPE_STRING = "String"; |
| | | |
| | | /** |
| | | * æ´å |
| | | */ |
| | | public static final String TYPE_INTEGER = "Integer"; |
| | | String TYPE_INTEGER = "Integer"; |
| | | |
| | | /** |
| | | * é¿æ´å |
| | | */ |
| | | public static final String TYPE_LONG = "Long"; |
| | | String TYPE_LONG = "Long"; |
| | | |
| | | /** |
| | | * æµ®ç¹å |
| | | */ |
| | | public static final String TYPE_DOUBLE = "Double"; |
| | | String TYPE_DOUBLE = "Double"; |
| | | |
| | | /** |
| | | * é«ç²¾åº¦è®¡ç®ç±»å |
| | | */ |
| | | public static final String TYPE_BIGDECIMAL = "BigDecimal"; |
| | | String TYPE_BIGDECIMAL = "BigDecimal"; |
| | | |
| | | /** |
| | | * æ¶é´ç±»å |
| | | */ |
| | | public static final String TYPE_DATE = "Date"; |
| | | String TYPE_DATE = "Date"; |
| | | |
| | | /** |
| | | * æ¨¡ç³æ¥è¯¢ |
| | | */ |
| | | public static final String QUERY_LIKE = "LIKE"; |
| | | String QUERY_LIKE = "LIKE"; |
| | | |
| | | /** |
| | | * éè¦ |
| | | */ |
| | | public static final String REQUIRE = "1"; |
| | | String REQUIRE = "1"; |
| | | } |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UserConstants { |
| | | public interface UserConstants { |
| | | |
| | | /** |
| | | * å¹³å°å
ç³»ç»ç¨æ·çå¯ä¸æ å¿ |
| | | */ |
| | | public static final String SYS_USER = "SYS_USER"; |
| | | String SYS_USER = "SYS_USER"; |
| | | |
| | | /** |
| | | * æ£å¸¸ç¶æ |
| | | */ |
| | | public static final String NORMAL = "0"; |
| | | String NORMAL = "0"; |
| | | |
| | | /** |
| | | * å¼å¸¸ç¶æ |
| | | */ |
| | | public static final String EXCEPTION = "1"; |
| | | String EXCEPTION = "1"; |
| | | |
| | | /** |
| | | * ç¨æ·å°ç¦ç¶æ |
| | | */ |
| | | public static final String USER_DISABLE = "1"; |
| | | String USER_DISABLE = "1"; |
| | | |
| | | /** |
| | | * è§è²å°ç¦ç¶æ |
| | | */ |
| | | public static final String ROLE_DISABLE = "1"; |
| | | String ROLE_DISABLE = "1"; |
| | | |
| | | /** |
| | | * é¨é¨æ£å¸¸ç¶æ |
| | | */ |
| | | public static final String DEPT_NORMAL = "0"; |
| | | String DEPT_NORMAL = "0"; |
| | | |
| | | /** |
| | | * é¨é¨åç¨ç¶æ |
| | | */ |
| | | public static final String DEPT_DISABLE = "1"; |
| | | String DEPT_DISABLE = "1"; |
| | | |
| | | /** |
| | | * åå
¸æ£å¸¸ç¶æ |
| | | */ |
| | | public static final String DICT_NORMAL = "0"; |
| | | String DICT_NORMAL = "0"; |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºç³»ç»é»è®¤ï¼æ¯ï¼ |
| | | */ |
| | | public static final String YES = "Y"; |
| | | String YES = "Y"; |
| | | |
| | | /** |
| | | * æ¯å¦èåå¤é¾ï¼æ¯ï¼ |
| | | */ |
| | | public static final String YES_FRAME = "0"; |
| | | String YES_FRAME = "0"; |
| | | |
| | | /** |
| | | * æ¯å¦èåå¤é¾ï¼å¦ï¼ |
| | | */ |
| | | public static final String NO_FRAME = "1"; |
| | | String NO_FRAME = "1"; |
| | | |
| | | /** |
| | | * èåç±»åï¼ç®å½ï¼ |
| | | */ |
| | | public static final String TYPE_DIR = "M"; |
| | | String TYPE_DIR = "M"; |
| | | |
| | | /** |
| | | * èåç±»åï¼èåï¼ |
| | | */ |
| | | public static final String TYPE_MENU = "C"; |
| | | String TYPE_MENU = "C"; |
| | | |
| | | /** |
| | | * èåç±»åï¼æé®ï¼ |
| | | */ |
| | | public static final String TYPE_BUTTON = "F"; |
| | | String TYPE_BUTTON = "F"; |
| | | |
| | | /** |
| | | * Layoutç»ä»¶æ è¯ |
| | | */ |
| | | public final static String LAYOUT = "Layout"; |
| | | String LAYOUT = "Layout"; |
| | | |
| | | /** |
| | | * ParentViewç»ä»¶æ è¯ |
| | | */ |
| | | public final static String PARENT_VIEW = "ParentView"; |
| | | String PARENT_VIEW = "ParentView"; |
| | | |
| | | /** |
| | | * InnerLinkç»ä»¶æ è¯ |
| | | */ |
| | | public final static String INNER_LINK = "InnerLink"; |
| | | String INNER_LINK = "InnerLink"; |
| | | |
| | | /** |
| | | * æ ¡éªè¿åç»æç |
| | | */ |
| | | public final static String UNIQUE = "0"; |
| | | public final static String NOT_UNIQUE = "1"; |
| | | String UNIQUE = "0"; |
| | | String NOT_UNIQUE = "1"; |
| | | |
| | | /** |
| | | * ç¨æ·åé¿åº¦éå¶ |
| | | */ |
| | | public static final int USERNAME_MIN_LENGTH = 2; |
| | | public static final int USERNAME_MAX_LENGTH = 20; |
| | | int USERNAME_MIN_LENGTH = 2; |
| | | int USERNAME_MAX_LENGTH = 20; |
| | | |
| | | /** |
| | | * å¯ç é¿åº¦éå¶ |
| | | */ |
| | | public static final int PASSWORD_MIN_LENGTH = 5; |
| | | public static final int PASSWORD_MAX_LENGTH = 20; |
| | | int PASSWORD_MIN_LENGTH = 5; |
| | | int PASSWORD_MAX_LENGTH = 20; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.sql.SqlUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å®ä½ç±» |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @Accessors(chain = true) |
| | | public class PageQuery implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | /** |
| | | * å½åè®°å½èµ·å§ç´¢å¼ é»è®¤å¼ |
| | | */ |
| | | public static final int DEFAULT_PAGE_NUM = 1; |
| | | |
| | | /** |
| | | * æ¯é¡µæ¾ç¤ºè®°å½æ° é»è®¤å¼ é»è®¤æ¥å
¨é¨ |
| | | */ |
| | | public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE; |
| | | |
| | | public <T> Page<T> build() { |
| | | Integer pageNum = ObjectUtil.defaultIfNull(getPageNum(), DEFAULT_PAGE_NUM); |
| | | Integer pageSize = ObjectUtil.defaultIfNull(getPageSize(), DEFAULT_PAGE_SIZE); |
| | | if (pageNum <= 0) { |
| | | pageNum = DEFAULT_PAGE_NUM; |
| | | } |
| | | Page<T> page = new Page<>(pageNum, pageSize); |
| | | OrderItem orderItem = buildOrderItem(); |
| | | if (ObjectUtil.isNotNull(orderItem)) { |
| | | page.addOrder(orderItem); |
| | | } |
| | | return page; |
| | | } |
| | | |
| | | private OrderItem buildOrderItem() { |
| | | // å
¼å®¹å端æåºç±»å |
| | | if ("ascending".equals(isAsc)) { |
| | | isAsc = "asc"; |
| | | } else if ("descending".equals(isAsc)) { |
| | | isAsc = "desc"; |
| | | } |
| | | if (StringUtils.isNotBlank(orderByColumn)) { |
| | | String orderBy = SqlUtil.escapeOrderBySql(orderByColumn); |
| | | orderBy = StringUtils.toUnderScoreCase(orderBy); |
| | | if ("asc".equals(isAsc)) { |
| | | return OrderItem.asc(orderBy); |
| | | } else if ("desc".equals(isAsc)) { |
| | | return OrderItem.desc(orderBy); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ruoyi.common.core.domain.TreeEntity; |
| | |
| | | * è·¯ç±åæ° |
| | | */ |
| | | @ApiModelProperty(value = "è·¯ç±åæ°") |
| | | @TableField("`query`") |
| | | private String query; |
| | | |
| | | /** |
| | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.xss.Xss; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | * ç¨æ·è´¦å· |
| | | */ |
| | | @ApiModelProperty(value = "ç¨æ·è´¦å·") |
| | | @NotBlank(message = "ç¨æ·è´¦å·ä¸è½ä¸ºç©º") |
| | | @Xss(message = "ç¨æ·è´¦å·ä¸è½å
å«èæ¬å符") |
| | | @NotBlank(message = "ç¨æ·è´¦å·ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "ç¨æ·è´¦å·é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | private String userName; |
| | | |
| | | /** |
| | | * ç¨æ·æµç§° |
| | | */ |
| | | @ApiModelProperty(value = "ç¨æ·æµç§°") |
| | | @Size(min = 0, max = 30, message = "ç¨æ·æµç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | @ApiModelProperty(value = "ç¨æ·æµç§°") |
| | | @Xss(message = "ç¨æ·æµç§°ä¸è½å
å«èæ¬å符") |
| | | @Size(min = 0, max = 30, message = "ç¨æ·æµç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | private String nickName; |
| | | |
| | | /** |
| | |
| | | private Long[] postIds; |
| | | |
| | | /** |
| | | * è§è²ID |
| | | * æ°æ®æé å½åè§è²ID |
| | | */ |
| | | @ApiModelProperty(value = "è§è²ID") |
| | | @TableField(exist = false) |
| | |
| | | package com.ruoyi.common.core.mybatisplus.core; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.BeanCopyUtils; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * èªå®ä¹ Mapper æ¥å£, å®ç° èªå®ä¹æ©å± |
| | |
| | | */ |
| | | int insertAll(@Param("list") Collection<T> batchList); |
| | | |
| | | /** |
| | | * æ ¹æ® ID æ¥è¯¢ |
| | | */ |
| | | default <V> V selectVoById(Serializable id, Class<V> voClass){ |
| | | T obj = this.selectById(id); |
| | | if (ObjectUtil.isNull(obj)) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.copy(obj, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ®ID æ¹éæ¥è¯¢ï¼ |
| | | */ |
| | | default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass){ |
| | | List<T> list = this.selectBatchIds(idList); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return BeanCopyUtils.copyList(list, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ® columnMap æ¡ä»¶ï¼ |
| | | */ |
| | | default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass){ |
| | | List<T> list = this.selectByMap(map); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return BeanCopyUtils.copyList(list, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® entity æ¡ä»¶ï¼æ¥è¯¢ä¸æ¡è®°å½ |
| | | */ |
| | | default <V> V selectVoOne(Wrapper<T> wrapper, Class<V> voClass) { |
| | | T obj = this.selectOne(wrapper); |
| | | if (ObjectUtil.isNull(obj)) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.copy(obj, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® entity æ¡ä»¶ï¼æ¥è¯¢å
¨é¨è®°å½ |
| | | */ |
| | | default <V> List<V> selectVoList(Wrapper<T> wrapper, Class<V> voClass) { |
| | | List<T> list = this.selectList(wrapper); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return BeanCopyUtils.copyList(list, voClass); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢VO |
| | | */ |
| | | default <V, P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<V> voClass) { |
| | | IPage<T> pageData = this.selectPage(page, wrapper); |
| | | IPage<V> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal()); |
| | | if (CollUtil.isEmpty(pageData.getRecords())) { |
| | | return (P) voPage; |
| | | } |
| | | voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass)); |
| | | return (P) voPage; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.common.core.mybatisplus.core; |
| | | |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | |
| | | |
| | | /** |
| | | * @param id 主é®id |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return V对象 |
| | | */ |
| | | V getVoById(Serializable id, CopyOptions copyOptions); |
| | | |
| | | default V getVoById(Serializable id) { |
| | | return getVoById(id, new CopyOptions()); |
| | | } |
| | | V getVoById(Serializable id); |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | |
| | | |
| | | /** |
| | | * @param idList idå表 |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return V对象 |
| | | */ |
| | | List<V> listVoByIds(Collection<? extends Serializable> idList, CopyOptions copyOptions); |
| | | |
| | | default List<V> listVoByIds(Collection<? extends Serializable> idList) { |
| | | return listVoByIds(idList, new CopyOptions()); |
| | | } |
| | | List<V> listVoByIds(Collection<? extends Serializable> idList); |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | |
| | | |
| | | /** |
| | | * @param columnMap è¡¨åæ®µ map 对象 |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return V对象 |
| | | */ |
| | | List<V> listVoByMap(Map<String, Object> columnMap, CopyOptions copyOptions); |
| | | |
| | | default List<V> listVoByMap(Map<String, Object> columnMap) { |
| | | return listVoByMap(columnMap, new CopyOptions()); |
| | | } |
| | | List<V> listVoByMap(Map<String, Object> columnMap); |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | |
| | | |
| | | /** |
| | | * @param queryWrapper æ¥è¯¢æ¡ä»¶ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return V对象 |
| | | */ |
| | | V getVoOne(Wrapper<T> queryWrapper, CopyOptions copyOptions); |
| | | |
| | | default V getVoOne(Wrapper<T> queryWrapper) { |
| | | return getVoOne(queryWrapper, new CopyOptions()); |
| | | } |
| | | V getVoOne(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | |
| | | |
| | | /** |
| | | * @param queryWrapper æ¥è¯¢æ¡ä»¶ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return V对象 |
| | | */ |
| | | List<V> listVo(Wrapper<T> queryWrapper, CopyOptions copyOptions); |
| | | |
| | | default List<V> listVo(Wrapper<T> queryWrapper) { |
| | | return listVo(queryWrapper, new CopyOptions()); |
| | | } |
| | | List<V> listVo(Wrapper<T> queryWrapper); |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | |
| | | /** |
| | | * @param page å页对象 |
| | | * @param queryWrapper æ¥è¯¢æ¡ä»¶ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return V对象 |
| | | * @deprecated 3.6.0 ç§»é¤ è¯·ä½¿ç¨ {@link ServicePlusImpl#pageVo(IPage, Wrapper)} |
| | | */ |
| | | PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper, CopyOptions copyOptions); |
| | | @Deprecated |
| | | PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper); |
| | | |
| | | default PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper) { |
| | | return pageVo(page, queryWrapper, new CopyOptions()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | * @deprecated 3.6.0 ç§»é¤ è¯·ä½¿ç¨ {@link ServicePlusImpl#pageVo(IPage, Wrapper)} |
| | | */ |
| | | @Deprecated |
| | | default PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper, |
| | | Function<Collection<T>, List<V>> convertor) { |
| | | PagePlus<T, V> result = getBaseMapper().selectPage(page, queryWrapper); |
| | | return result.setRecordsVo(convertor.apply(result.getRecords())); |
| | | } |
| | | |
| | | /** |
| | | * @deprecated 3.6.0 ç§»é¤ è¯·ä½¿ç¨ {@link ServicePlusImpl#pageVo(IPage, Wrapper)} |
| | | */ |
| | | @Deprecated |
| | | default PagePlus<T, V> pageVo(PagePlus<T, V> page) { |
| | | return pageVo(page, Wrappers.emptyWrapper()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | * @deprecated 3.6.0 ç§»é¤ è¯·ä½¿ç¨ {@link ServicePlusImpl#pageVo(IPage, Wrapper)} |
| | | */ |
| | | @Deprecated |
| | | default PagePlus<T, V> pageVo(PagePlus<T, V> page, Function<Collection<T>, List<V>> convertor) { |
| | | return pageVo(page, Wrappers.emptyWrapper(), convertor); |
| | | } |
| | |
| | | package com.ruoyi.common.core.mybatisplus.core; |
| | | |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Assert; |
| | |
| | | |
| | | /** |
| | | * æ ¹æ® ID æ¥è¯¢ |
| | | * |
| | | * @param id 主é®ID |
| | | */ |
| | | @Override |
| | | public V getVoById(Serializable id, CopyOptions copyOptions) { |
| | | T t = getBaseMapper().selectById(id); |
| | | return BeanCopyUtils.oneCopy(t, copyOptions, voClass); |
| | | public V getVoById(Serializable id) { |
| | | return getBaseMapper().selectVoById(id, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ®ID æ¹éæ¥è¯¢ï¼ |
| | | * |
| | | * @param idList 主é®IDå表 |
| | | */ |
| | | @Override |
| | | public List<V> listVoByIds(Collection<? extends Serializable> idList, CopyOptions copyOptions) { |
| | | List<T> list = getBaseMapper().selectBatchIds(idList); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.listCopy(list, copyOptions, voClass); |
| | | public List<V> listVoByIds(Collection<? extends Serializable> idList) { |
| | | return getBaseMapper().selectVoBatchIds(idList, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ® columnMap æ¡ä»¶ï¼ |
| | | * |
| | | * @param columnMap è¡¨åæ®µ map 对象 |
| | | */ |
| | | @Override |
| | | public List<V> listVoByMap(Map<String, Object> columnMap, CopyOptions copyOptions) { |
| | | List<T> list = getBaseMapper().selectByMap(columnMap); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.listCopy(list, copyOptions, voClass); |
| | | public List<V> listVoByMap(Map<String, Object> columnMap) { |
| | | return getBaseMapper().selectVoByMap(columnMap, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® Wrapperï¼æ¥è¯¢ä¸æ¡è®°å½ <br/> |
| | | * <p>ç»æéï¼å¦ææ¯å¤ä¸ªä¼æåºå¼å¸¸ï¼éæºå䏿¡å ä¸éå¶æ¡ä»¶ wrapper.last("LIMIT 1")</p> |
| | | * |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | @Override |
| | | public V getVoOne(Wrapper<T> queryWrapper, CopyOptions copyOptions) { |
| | | T t = getOne(queryWrapper, true); |
| | | return BeanCopyUtils.oneCopy(t, copyOptions, voClass); |
| | | public V getVoOne(Wrapper<T> queryWrapper) { |
| | | return getBaseMapper().selectVoOne(queryWrapper, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | * |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | @Override |
| | | public List<V> listVo(Wrapper<T> queryWrapper, CopyOptions copyOptions) { |
| | | List<T> list = getBaseMapper().selectList(queryWrapper); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.listCopy(list, copyOptions, voClass); |
| | | public List<V> listVo(Wrapper<T> queryWrapper) { |
| | | return getBaseMapper().selectVoList(queryWrapper, voClass); |
| | | } |
| | | |
| | | /** |
| | | * 翻页æ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» |
| | | * @deprecated 3.6.0 ç§»é¤ è¯·ä½¿ç¨ {@link #pageVo(IPage, Wrapper)} |
| | | */ |
| | | @Override |
| | | public PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper, CopyOptions copyOptions) { |
| | | @Deprecated |
| | | public PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper) { |
| | | PagePlus<T, V> result = getBaseMapper().selectPage(page, queryWrapper); |
| | | List<V> volist = BeanCopyUtils.listCopy(result.getRecords(), copyOptions, voClass); |
| | | List<V> volist = BeanCopyUtils.copyList(result.getRecords(), voClass); |
| | | result.setRecordsVo(volist); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 翻页æ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» |
| | | */ |
| | | public <P extends IPage<V>> P pageVo(IPage<T> page, Wrapper<T> queryWrapper) { |
| | | return getBaseMapper().selectVoPage(page, queryWrapper, voClass); |
| | | } |
| | | |
| | | } |
| | |
| | | * @param <T> æ°æ®åºå®ä½ |
| | | * @param <K> voå®ä½ |
| | | * @author Lion Li |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link com.ruoyi.common.core.domain.PageQuery#build()} |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @Deprecated |
| | | public class PagePlus<T,K> implements IPage<T> { |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | this.total = total; |
| | | } |
| | | |
| | | public static <T> TableDataInfo<T> build(IPage<T> page) { |
| | | TableDataInfo<T> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | | rspData.setMsg("æ¥è¯¢æå"); |
| | | rspData.setRows(page.getRecords()); |
| | | rspData.setTotal(page.getTotal()); |
| | | return rspData; |
| | | } |
| | | |
| | | public static <T> TableDataInfo<T> build(List<T> list) { |
| | | TableDataInfo<T> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | | rspData.setMsg("æ¥è¯¢æå"); |
| | | rspData.setRows(list); |
| | | rspData.setTotal(list.size()); |
| | | return rspData; |
| | | } |
| | | |
| | | public static <T> TableDataInfo<T> build() { |
| | | TableDataInfo<T> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | | rspData.setMsg("æ¥è¯¢æå"); |
| | | return rspData; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * æ°æ®æéç±»å |
| | | * |
| | | * è¯æ³æ¯æ spel 模æ¿è¡¨è¾¾å¼ |
| | | * |
| | | * å
ç½®æ°æ® user å½åç¨æ· å
容åè SysUser |
| | | * å¦éæ©å±æ°æ® å¯ä½¿ç¨ {@link com.ruoyi.common.helper.DataPermissionHelper} æä½ |
| | | * å
ç½®æå¡ sdss ç³»ç»æ°æ®æéæå¡ å
容åè SysDataScopeService |
| | | * å¦éæ©å±æ´å¤èªå®ä¹æå¡ å¯ä»¥åè sdss èªè¡ç¼å |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.5.0 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DataScopeType { |
| | | |
| | | /** |
| | | * å
¨é¨æ°æ®æé |
| | | */ |
| | | ALL("1", "", ""), |
| | | |
| | | /** |
| | | * èªå®æ°æ®æé |
| | | */ |
| | | CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", ""), |
| | | |
| | | /** |
| | | * é¨é¨æ°æ®æé |
| | | */ |
| | | DEPT("3", " #{#deptName} = #{#user.deptId} ", ""), |
| | | |
| | | /** |
| | | * é¨é¨å以䏿°æ®æé |
| | | */ |
| | | DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", ""), |
| | | |
| | | /** |
| | | * ä»
æ¬äººæ°æ®æé |
| | | */ |
| | | SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 "); |
| | | |
| | | private final String code; |
| | | |
| | | /** |
| | | * è¯æ³ éç¨ spel 模æ¿è¡¨è¾¾å¼ |
| | | */ |
| | | private final String sqlTemplate; |
| | | |
| | | /** |
| | | * 䏿»¡è¶³ sqlTemplate åå¡«å
|
| | | */ |
| | | private final String elseSql; |
| | | |
| | | public static DataScopeType findCode(String code) { |
| | | if (StringUtils.isBlank(code)) { |
| | | return null; |
| | | } |
| | | for (DataScopeType type : values()) { |
| | | if (type.getCode().equals(code)) { |
| | | return type; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | * æ°æ®æº |
| | | * |
| | | * @author Lion Li |
| | | * @deprecated 3.6.0 ç§»é¤ |
| | | */ |
| | | @AllArgsConstructor |
| | | @Deprecated |
| | | public enum DataSourceType { |
| | | /** |
| | | * ä¸»åº |
| | |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelAnalysisException; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Override |
| | | public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
| | | this.headMap = headMap; |
| | | log.debug("è§£æå°ä¸æ¡è¡¨å¤´æ°æ®: {}", JSON.toJSONString(headMap)); |
| | | log.debug("è§£æå°ä¸æ¡è¡¨å¤´æ°æ®: {}", JsonUtils.toJsonString(headMap)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public CaptchaException() { |
| | | super("user.jcaptcha.error", null); |
| | | super("user.jcaptcha.error"); |
| | | } |
| | | } |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public CaptchaExpireException() { |
| | | super("user.jcaptcha.expire", null); |
| | | super("user.jcaptcha.expire"); |
| | | } |
| | | } |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public UserPasswordNotMatchException() { |
| | | super("user.password.not.match", null); |
| | | super("user.password.not.match"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.helper; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * æ°æ®æé婿 |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.5.0 |
| | | */ |
| | | @SuppressWarnings("unchecked cast") |
| | | public class DataPermissionHelper { |
| | | |
| | | private static final String DATA_PERMISSION_KEY = "data:permission"; |
| | | |
| | | public static <T> T getVariable(String key) { |
| | | Map<String, Object> context = getContext(); |
| | | return (T) context.get(key); |
| | | } |
| | | |
| | | |
| | | |
| | | public static void setVariable(String key, Object value) { |
| | | Map<String, Object> context = getContext(); |
| | | context.put(key, value); |
| | | } |
| | | |
| | | public static Map<String, Object> getContext() { |
| | | HttpServletRequest request = ServletUtils.getRequest(); |
| | | Object attribute = request.getAttribute(DATA_PERMISSION_KEY); |
| | | if (ObjectUtil.isNull(attribute)) { |
| | | request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>()); |
| | | attribute = request.getAttribute(DATA_PERMISSION_KEY); |
| | | } |
| | | if (attribute instanceof Map) { |
| | | return (Map<String, Object>) attribute; |
| | | } |
| | | throw new NullPointerException("data permission context type exception"); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.bean.copier.BeanCopier; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.map.MapUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import cn.hutool.extra.cglib.CglibUtil; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * beanæ·±æ·è´å·¥å
· |
| | | * beanæ·±æ·è´å·¥å
·(åºäº cglib æ§è½ä¼å¼) |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class BeanCopyUtils { |
| | | |
| | | /** |
| | | * å对象åºäºclasså建æ·è´ |
| | | * |
| | | * @param source æ°æ®æ¥æºå®ä½ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @param desc æè¿°å¯¹è±¡ 转æ¢åç对象 |
| | | * @param source æ°æ®æ¥æºå®ä½ |
| | | * @param desc æè¿°å¯¹è±¡ 转æ¢åç对象 |
| | | * @return desc |
| | | */ |
| | | public static <T, V> V oneCopy(T source, CopyOptions copyOptions, Class<V> desc) { |
| | | V v = ReflectUtil.newInstanceIfPossible(desc); |
| | | return oneCopy(source, copyOptions, v); |
| | | public static <T, V> V copy(T source, Class<V> desc) { |
| | | if (ObjectUtil.isNull(source)) { |
| | | return null; |
| | | } |
| | | if (ObjectUtil.isNull(desc)) { |
| | | return null; |
| | | } |
| | | return CglibUtil.copy(source, desc); |
| | | } |
| | | |
| | | /** |
| | | * å对象åºäºå¯¹è±¡å建æ·è´ |
| | | * |
| | | * @param source æ°æ®æ¥æºå®ä½ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @param desc 转æ¢åç对象 |
| | | * @param source æ°æ®æ¥æºå®ä½ |
| | | * @param desc 转æ¢åç对象 |
| | | * @return desc |
| | | */ |
| | | public static <T, V> V oneCopy(T source, CopyOptions copyOptions, V desc) { |
| | | public static <T, V> V copy(T source, V desc) { |
| | | if (ObjectUtil.isNull(source)) { |
| | | return null; |
| | | } |
| | | return BeanCopier.create(source, desc, copyOptions).copy(); |
| | | if (ObjectUtil.isNull(desc)) { |
| | | return null; |
| | | } |
| | | CglibUtil.copy(source, desc); |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * å表对象åºäºclasså建æ·è´ |
| | | * |
| | | * @param sourceList æ°æ®æ¥æºå®ä½å表 |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @param desc æè¿°å¯¹è±¡ 转æ¢åç对象 |
| | | * @param sourceList æ°æ®æ¥æºå®ä½å表 |
| | | * @param desc æè¿°å¯¹è±¡ 转æ¢åç对象 |
| | | * @return desc |
| | | */ |
| | | public static <T, V> List<V> listCopy(List<T> sourceList, CopyOptions copyOptions, Class<V> desc) { |
| | | public static <T, V> List<V> copyList(List<T> sourceList, Class<V> desc) { |
| | | if (ObjectUtil.isNull(sourceList)) { |
| | | return null; |
| | | } |
| | | if (CollUtil.isEmpty(sourceList)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return sourceList.stream() |
| | | .map(source -> oneCopy(source, copyOptions, desc)) |
| | | .collect(Collectors.toList()); |
| | | return CglibUtil.copyList(sourceList, () -> ReflectUtil.newInstanceIfPossible(desc)); |
| | | } |
| | | |
| | | /** |
| | | * beanæ·è´å°map |
| | | * |
| | | * @param bean æ°æ®æ¥æºå®ä½ |
| | | * @return map对象 |
| | | */ |
| | | public static <T> Map<String, Object> copyToMap(T bean) { |
| | | if (ObjectUtil.isNull(bean)) { |
| | | return null; |
| | | } |
| | | return CglibUtil.toMap(bean); |
| | | } |
| | | |
| | | /** |
| | | * mapæ·è´å°bean |
| | | * |
| | | * @param map æ°æ®æ¥æº |
| | | * @param beanClass beanç±» |
| | | * @return bean对象 |
| | | */ |
| | | public static <T> T mapToBean(Map<String, Object> map, Class<T> beanClass) { |
| | | if (MapUtil.isEmpty(map)) { |
| | | return null; |
| | | } |
| | | if (ObjectUtil.isNull(beanClass)) { |
| | | return null; |
| | | } |
| | | return CglibUtil.toBean(map, beanClass); |
| | | } |
| | | |
| | | /** |
| | | * mapæ·è´å°bean |
| | | * |
| | | * @param map æ°æ®æ¥æº |
| | | * @param bean bean对象 |
| | | * @return bean对象 |
| | | */ |
| | | public static <T> T mapToBean(Map<String, Object> map, T bean) { |
| | | if (MapUtil.isEmpty(map)) { |
| | | return null; |
| | | } |
| | | if (ObjectUtil.isNull(bean)) { |
| | | return null; |
| | | } |
| | | return CglibUtil.fillBean(map, bean); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | |
| | | import java.lang.management.ManagementFactory; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class DateUtils extends org.apache.commons.lang3.time.DateUtils { |
| | | |
| | | public static String YYYY = "yyyy"; |
| | |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class JsonUtils { |
| | | |
| | | private static ObjectMapper objectMapper = SpringUtils.getBean(ObjectMapper.class); |
| | | private static final ObjectMapper OBJECT_MAPPER = SpringUtils.getBean(ObjectMapper.class); |
| | | |
| | | public static ObjectMapper getObjectMapper() { |
| | | return OBJECT_MAPPER; |
| | | } |
| | | |
| | | public static String toJsonString(Object object) { |
| | | if (StringUtils.isNull(object)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return objectMapper.writeValueAsString(object); |
| | | return OBJECT_MAPPER.writeValueAsString(object); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | try { |
| | | return objectMapper.readValue(text, clazz); |
| | | return OBJECT_MAPPER.readValue(text, clazz); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | try { |
| | | return objectMapper.readValue(bytes, clazz); |
| | | return OBJECT_MAPPER.readValue(bytes, clazz); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | try { |
| | | return objectMapper.readValue(text, typeReference); |
| | | return OBJECT_MAPPER.readValue(text, typeReference); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | try { |
| | | return objectMapper.readValue(text, new TypeReference<Map<String, T>>() { |
| | | return OBJECT_MAPPER.readValue(text, new TypeReference<Map<String, T>>() { |
| | | }); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | try { |
| | | return objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)); |
| | | return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, clazz)); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.context.i18n.LocaleContextHolder; |
| | | |
| | | /** |
| | | * è·åi18nèµæºæä»¶ |
| | | * |
| | | * @author ruoyi |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class MessageUtils { |
| | | |
| | | private static final MessageSource MESSAGE_SOURCE = SpringUtils.getBean(MessageSource.class); |
| | | |
| | | /** |
| | | * æ ¹æ®æ¶æ¯é®ååæ° è·åæ¶æ¯ å§æç»spring messageSource |
| | | * |
| | |
| | | * @return è·åå½é
åç¿»è¯å¼ |
| | | */ |
| | | public static String message(String code, Object... args) { |
| | | MessageSource messageSource = SpringUtils.getBean(MessageSource.class); |
| | | return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); |
| | | return MESSAGE_SOURCE.getMessage(code, args, LocaleContextHolder.getLocale()); |
| | | } |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.sql.SqlUtil; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * å页工å
· |
| | | * |
| | | * @author Lion Li |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link PageQuery} ä¸ {@link TableDataInfo} |
| | | */ |
| | | @Deprecated |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class PageUtils { |
| | | |
| | | /** |
| | | * å½åè®°å½èµ·å§ç´¢å¼ |
| | | */ |
| | | @Deprecated |
| | | public static final String PAGE_NUM = "pageNum"; |
| | | |
| | | /** |
| | | * æ¯é¡µæ¾ç¤ºè®°å½æ° |
| | | */ |
| | | @Deprecated |
| | | public static final String PAGE_SIZE = "pageSize"; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @Deprecated |
| | | public static final String ORDER_BY_COLUMN = "orderByColumn"; |
| | | |
| | | /** |
| | | * æåºçæ¹å "desc" æè
"asc". |
| | | */ |
| | | @Deprecated |
| | | public static final String IS_ASC = "isAsc"; |
| | | |
| | | /** |
| | | * å½åè®°å½èµ·å§ç´¢å¼ é»è®¤å¼ |
| | | */ |
| | | @Deprecated |
| | | public static final int DEFAULT_PAGE_NUM = 1; |
| | | |
| | | /** |
| | | * æ¯é¡µæ¾ç¤ºè®°å½æ° é»è®¤å¼ é»è®¤æ¥å
¨é¨ |
| | | */ |
| | | @Deprecated |
| | | public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE; |
| | | |
| | | /** |
| | |
| | | * @param <T> domain å®ä½ |
| | | * @param <K> vo å®ä½ |
| | | * @return å页对象 |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link PageQuery#build()} |
| | | * ç±äºä½¿ç¨ Servlet è·ååªè½ä» param è·å çµæ´»æ§éä½ æ
å°ä¼ åæä½äº¤ç»ç¨æ· |
| | | */ |
| | | @Deprecated |
| | | public static <T, K> PagePlus<T, K> buildPagePlus() { |
| | | Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM); |
| | | Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE); |
| | |
| | | return page; |
| | | } |
| | | |
| | | @Deprecated |
| | | public static <T> Page<T> buildPage() { |
| | | return buildPage(null, null); |
| | | } |
| | |
| | | * |
| | | * @param <T> domain å®ä½ |
| | | * @return å页对象 |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link PageQuery#build()} |
| | | * ç±äºä½¿ç¨ Servlet è·ååªè½ä» param è·å çµæ´»æ§éä½ æ
å°ä¼ åæä½äº¤ç»ç¨æ· |
| | | */ |
| | | @Deprecated |
| | | public static <T> Page<T> buildPage(String defaultOrderByColumn, String defaultIsAsc) { |
| | | Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM); |
| | | Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æå»º MP æ®éå页对象 |
| | | * |
| | | * @param <T> domain å®ä½ |
| | | * @return å页对象 |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link PageQuery#build()} |
| | | * ç±äºä½¿ç¨ Servlet è·ååªè½ä» param è·å çµæ´»æ§éä½ æ
å°ä¼ åæä½äº¤ç»ç¨æ· |
| | | */ |
| | | @Deprecated |
| | | public static <T, K> TableDataInfo<K> buildDataInfo(PagePlus<T, K> page) { |
| | | TableDataInfo<K> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | |
| | | return rspData; |
| | | } |
| | | |
| | | /** |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link TableDataInfo#build(IPage)} |
| | | */ |
| | | @Deprecated |
| | | public static <T> TableDataInfo<T> buildDataInfo(Page<T> page) { |
| | | TableDataInfo<T> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | |
| | | return rspData; |
| | | } |
| | | |
| | | /** |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link TableDataInfo#build(List)} |
| | | */ |
| | | @Deprecated |
| | | public static <T> TableDataInfo<T> buildDataInfo(List<T> list) { |
| | | TableDataInfo<T> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | |
| | | return rspData; |
| | | } |
| | | |
| | | /** |
| | | * @deprecated 3.6.0 å é¤ è¯·ä½¿ç¨ {@link TableDataInfo#build()} |
| | | */ |
| | | @Deprecated |
| | | public static <T> TableDataInfo<T> buildDataInfo() { |
| | | TableDataInfo<T> rspData = new TableDataInfo<>(); |
| | | rspData.setCode(HttpStatus.HTTP_OK); |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import cn.hutool.core.collection.IterUtil; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | |
| | | @SuppressWarnings(value = {"unchecked", "rawtypes"}) |
| | | public class RedisUtils { |
| | | |
| | | private static RedissonClient client = SpringUtils.getBean(RedissonClient.class); |
| | | private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class); |
| | | |
| | | /** |
| | | * éæµ |
| | |
| | | * @return -1 表示失败 |
| | | */ |
| | | public static long rateLimiter(String key, RateType rateType, int rate, int rateInterval) { |
| | | RRateLimiter rateLimiter = client.getRateLimiter(key); |
| | | RRateLimiter rateLimiter = CLIENT.getRateLimiter(key); |
| | | rateLimiter.trySetRate(rateType, rate, rateInterval, RateIntervalUnit.SECONDS); |
| | | if (rateLimiter.tryAcquire()) { |
| | | return rateLimiter.availablePermits(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åå®ä¾id |
| | | * è·å客æ·ç«¯å®ä¾ |
| | | */ |
| | | public static String getClientId() { |
| | | return client.getId(); |
| | | public static RedissonClient getClient() { |
| | | return CLIENT; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param consumer èªå®ä¹å¤ç |
| | | */ |
| | | public static <T> void publish(String channelKey, T msg, Consumer<T> consumer) { |
| | | RTopic topic = client.getTopic(channelKey); |
| | | RTopic topic = CLIENT.getTopic(channelKey); |
| | | topic.publish(msg); |
| | | consumer.accept(msg); |
| | | } |
| | | |
| | | public static <T> void publish(String channelKey, T msg) { |
| | | RTopic topic = client.getTopic(channelKey); |
| | | RTopic topic = CLIENT.getTopic(channelKey); |
| | | topic.publish(msg); |
| | | } |
| | | |
| | |
| | | * @param consumer èªå®ä¹å¤ç |
| | | */ |
| | | public static <T> void subscribe(String channelKey, Class<T> clazz, Consumer<T> consumer) { |
| | | RTopic topic = client.getTopic(channelKey); |
| | | RTopic topic = CLIENT.getTopic(channelKey); |
| | | topic.addListener(clazz, (channel, msg) -> consumer.accept(msg)); |
| | | } |
| | | |
| | |
| | | /** |
| | | * ç¼ååºæ¬ç对象ï¼ä¿çå½å对象 TTL æææ |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param value ç¼åçå¼ |
| | | * @param key ç¼åçé®å¼ |
| | | * @param value ç¼åçå¼ |
| | | * @param isSaveTtl æ¯å¦ä¿çTTLæææ(ä¾å¦: setä¹åttlå©ä½90 setä¹åè¿æ¯ä¸º90) |
| | | * @since Redis 6.X 以ä¸ä½¿ç¨ setAndKeepTTL å
¼å®¹ 5.X æ¹æ¡ |
| | | */ |
| | | public static <T> void setCacheObject(final String key, final T value, final boolean isSaveTtl) { |
| | | RBucket<Object> bucket = client.getBucket(key); |
| | | RBucket<Object> bucket = CLIENT.getBucket(key); |
| | | if (isSaveTtl) { |
| | | try { |
| | | bucket.setAndKeepTTL(value); |
| | |
| | | * @param timeUnit æ¶é´é¢ç²åº¦ |
| | | */ |
| | | public static <T> void setCacheObject(final String key, final T value, final long timeout, final TimeUnit timeUnit) { |
| | | RBucket<T> result = client.getBucket(key); |
| | | RBucket<T> result = CLIENT.getBucket(key); |
| | | result.set(value); |
| | | result.expire(timeout, timeUnit); |
| | | } |
| | | |
| | | /** |
| | | * 注å对象çå¬å¨ |
| | | * |
| | | * key çå¬å¨éå¼å¯ `notify-keyspace-events` ç redis ç¸å
³é
ç½® |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param listener çå¬å¨é
ç½® |
| | | */ |
| | | public static <T> void addObjectListener(final String key, final ObjectListener listener) { |
| | | RBucket<T> result = CLIENT.getBucket(key); |
| | | result.addListener(listener); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return true=设置æåï¼false=设置失败 |
| | | */ |
| | | public static boolean expire(final String key, final long timeout, final TimeUnit unit) { |
| | | RBucket rBucket = client.getBucket(key); |
| | | RBucket rBucket = CLIENT.getBucket(key); |
| | | return rBucket.expire(timeout, unit); |
| | | } |
| | | |
| | |
| | | * @return ç¼åé®å¼å¯¹åºçæ°æ® |
| | | */ |
| | | public static <T> T getCacheObject(final String key) { |
| | | RBucket<T> rBucket = client.getBucket(key); |
| | | RBucket<T> rBucket = CLIENT.getBucket(key); |
| | | return rBucket.get(); |
| | | } |
| | | |
| | |
| | | * @return å©ä½åæ´»æ¶é´ |
| | | */ |
| | | public static <T> long getTimeToLive(final String key) { |
| | | RBucket<T> rBucket = client.getBucket(key); |
| | | RBucket<T> rBucket = CLIENT.getBucket(key); |
| | | return rBucket.remainTimeToLive(); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å个对象 |
| | | * |
| | | * @param key |
| | | * @param key ç¼åçé®å¼ |
| | | */ |
| | | public static boolean deleteObject(final String key) { |
| | | return client.getBucket(key).delete(); |
| | | return CLIENT.getBucket(key).delete(); |
| | | } |
| | | |
| | | /* */ |
| | | |
| | | /** |
| | | * å é¤éå对象 |
| | | * |
| | | * @param collection å¤ä¸ªå¯¹è±¡ |
| | | * @return |
| | | */ |
| | | public static void deleteObject(final Collection collection) { |
| | | RBatch batch = client.createBatch(); |
| | | RBatch batch = CLIENT.createBatch(); |
| | | collection.forEach(t -> { |
| | | batch.getBucket(t.toString()).deleteAsync(); |
| | | }); |
| | |
| | | * @return ç¼åç对象 |
| | | */ |
| | | public static <T> boolean setCacheList(final String key, final List<T> dataList) { |
| | | RList<T> rList = client.getList(key); |
| | | RList<T> rList = CLIENT.getList(key); |
| | | return rList.addAll(dataList); |
| | | } |
| | | |
| | | /** |
| | | * 注åListçå¬å¨ |
| | | * |
| | | * key çå¬å¨éå¼å¯ `notify-keyspace-events` ç redis ç¸å
³é
ç½® |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param listener çå¬å¨é
ç½® |
| | | */ |
| | | public static <T> void addListListener(final String key, final ObjectListener listener) { |
| | | RList<T> rList = CLIENT.getList(key); |
| | | rList.addListener(listener); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ç¼åé®å¼å¯¹åºçæ°æ® |
| | | */ |
| | | public static <T> List<T> getCacheList(final String key) { |
| | | RList<T> rList = client.getList(key); |
| | | RList<T> rList = CLIENT.getList(key); |
| | | return rList.readAll(); |
| | | } |
| | | |
| | |
| | | * @return ç¼åæ°æ®ç对象 |
| | | */ |
| | | public static <T> boolean setCacheSet(final String key, final Set<T> dataSet) { |
| | | RSet<T> rSet = client.getSet(key); |
| | | RSet<T> rSet = CLIENT.getSet(key); |
| | | return rSet.addAll(dataSet); |
| | | } |
| | | |
| | | /** |
| | | * 注åSetçå¬å¨ |
| | | * |
| | | * key çå¬å¨éå¼å¯ `notify-keyspace-events` ç redis ç¸å
³é
ç½® |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param listener çå¬å¨é
ç½® |
| | | */ |
| | | public static <T> void addSetListener(final String key, final ObjectListener listener) { |
| | | RSet<T> rSet = CLIENT.getSet(key); |
| | | rSet.addListener(listener); |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçset |
| | | * |
| | | * @param key |
| | | * @return |
| | | * @param key ç¼åçkey |
| | | * @return set对象 |
| | | */ |
| | | public static <T> Set<T> getCacheSet(final String key) { |
| | | RSet<T> rSet = client.getSet(key); |
| | | RSet<T> rSet = CLIENT.getSet(key); |
| | | return rSet.readAll(); |
| | | } |
| | | |
| | | /** |
| | | * ç¼åMap |
| | | * |
| | | * @param key |
| | | * @param dataMap |
| | | * @param key ç¼åçé®å¼ |
| | | * @param dataMap ç¼åçæ°æ® |
| | | */ |
| | | public static <T> void setCacheMap(final String key, final Map<String, T> dataMap) { |
| | | if (dataMap != null) { |
| | | RMap<String, T> rMap = client.getMap(key); |
| | | RMap<String, T> rMap = CLIENT.getMap(key); |
| | | rMap.putAll(dataMap); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 注åMapçå¬å¨ |
| | | * |
| | | * key çå¬å¨éå¼å¯ `notify-keyspace-events` ç redis ç¸å
³é
ç½® |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param listener çå¬å¨é
ç½® |
| | | */ |
| | | public static <T> void addMapListener(final String key, final ObjectListener listener) { |
| | | RMap<String, T> rMap = CLIENT.getMap(key); |
| | | rMap.addListener(listener); |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçMap |
| | | * |
| | | * @param key |
| | | * @return |
| | | * @param key ç¼åçé®å¼ |
| | | * @return map对象 |
| | | */ |
| | | public static <T> Map<String, T> getCacheMap(final String key) { |
| | | RMap<String, T> rMap = client.getMap(key); |
| | | RMap<String, T> rMap = CLIENT.getMap(key); |
| | | return rMap.getAll(rMap.keySet()); |
| | | } |
| | | |
| | |
| | | * @param value å¼ |
| | | */ |
| | | public static <T> void setCacheMapValue(final String key, final String hKey, final T value) { |
| | | RMap<String, T> rMap = client.getMap(key); |
| | | RMap<String, T> rMap = CLIENT.getMap(key); |
| | | rMap.put(hKey, value); |
| | | } |
| | | |
| | |
| | | * @return Hashä¸ç对象 |
| | | */ |
| | | public static <T> T getCacheMapValue(final String key, final String hKey) { |
| | | RMap<String, T> rMap = client.getMap(key); |
| | | RMap<String, T> rMap = CLIENT.getMap(key); |
| | | return rMap.get(hKey); |
| | | } |
| | | |
| | |
| | | * @return Hashä¸ç对象 |
| | | */ |
| | | public static <T> T delCacheMapValue(final String key, final String hKey) { |
| | | RMap<String, T> rMap = client.getMap(key); |
| | | RMap<String, T> rMap = CLIENT.getMap(key); |
| | | return rMap.remove(hKey); |
| | | } |
| | | |
| | |
| | | * @return Hash对象éå |
| | | */ |
| | | public static <K, V> Map<K, V> getMultiCacheMapValue(final String key, final Set<K> hKeys) { |
| | | RMap<K, V> rMap = client.getMap(key); |
| | | RMap<K, V> rMap = CLIENT.getMap(key); |
| | | return rMap.getAll(hKeys); |
| | | } |
| | | |
| | |
| | | * @return 对象å表 |
| | | */ |
| | | public static Collection<String> keys(final String pattern) { |
| | | Iterable<String> iterable = client.getKeys().getKeysByPattern(pattern); |
| | | return Lists.newArrayList(iterable); |
| | | Iterable<String> iterable = CLIENT.getKeys().getKeysByPattern(pattern); |
| | | return IterUtil.toList(iterable); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.service.UserService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Long Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class SecurityUtils { |
| | | |
| | | /** |
| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.extra.servlet.ServletUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class ServletUtils extends ServletUtil { |
| | | |
| | | /** |
| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.ReUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class StringUtils extends org.apache.commons.lang3.StringUtils { |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.concurrent.*; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class Threads { |
| | | private static final Logger logger = LoggerFactory.getLogger(Threads.class); |
| | | |
| | | /** |
| | | * sleepçå¾
,åä½ä¸ºæ¯«ç§ |
| | |
| | | if (!pool.awaitTermination(120, TimeUnit.SECONDS)) { |
| | | pool.shutdownNow(); |
| | | if (!pool.awaitTermination(120, TimeUnit.SECONDS)) { |
| | | logger.info("Pool did not terminate"); |
| | | log.info("Pool did not terminate"); |
| | | } |
| | | } |
| | | } catch (InterruptedException ie) { |
| | |
| | | } |
| | | } |
| | | if (t != null) { |
| | | logger.error(t.getMessage(), t); |
| | | log.error(t.getMessage(), t); |
| | | } |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.lang.tree.TreeNodeConfig; |
| | | import cn.hutool.core.lang.tree.TreeUtil; |
| | | import cn.hutool.core.lang.tree.parser.NodeParser; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class TreeBuildUtils extends TreeUtil { |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label"); |
| | | |
| | | /** |
| | | * é»è®¤æ ç¶èç¹id |
| | | */ |
| | | public static final Long DEFAULT_PARENT_ID = 0L; |
| | | |
| | | public static <T> List<Tree<Long>> build(List<T> list, NodeParser<T, Long> nodeParser) { |
| | | return TreeUtil.build(list, DEFAULT_PARENT_ID, DEFAULT_CONFIG, nodeParser); |
| | | public static <T> List<Tree<Long>> build(List<T> list, Long parentId, NodeParser<T, Long> nodeParser) { |
| | | return TreeUtil.build(list, parentId, DEFAULT_CONFIG, nodeParser); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import javax.validation.ConstraintViolation; |
| | | import javax.validation.ConstraintViolationException; |
| | | import javax.validation.Validation; |
| | | import javax.validation.Validator; |
| | | import java.util.Set; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class ValidatorUtils { |
| | | |
| | | private static final Validator VALID = Validation.buildDefaultValidatorFactory().getValidator(); |
| | | private static final Validator VALID = SpringUtils.getBean(Validator.class); |
| | | |
| | | public static <T> void validate(T object, Class<?>... groups) { |
| | | Set<ConstraintViolation<T>> validate = VALID.validate(object, groups); |
| | |
| | | package com.ruoyi.common.utils.file; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class FileUtils extends FileUtil { |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.Map; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class AddressUtils { |
| | | |
| | | // IPå°åæ¥è¯¢ |
| | |
| | | import com.ruoyi.common.excel.ExcelResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class ExcelUtil { |
| | | |
| | | /** |
| | |
| | | |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.lang.reflect.Method; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class ReflectUtils extends ReflectUtil { |
| | | |
| | | private static final String SETTER_PREFIX = "set"; |
| | |
| | | |
| | | import com.ruoyi.common.exception.UtilException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * sqlæä½å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class SqlUtil { |
| | | |
| | | /** |
| | | * å®ä¹å¸¸ç¨ç sqlå
³é®å |
| | | */ |
| | | public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare "; |
| | | |
| | | /** |
| | | * ä»
æ¯æåæ¯ãæ°åãä¸å线ãç©ºæ ¼ãéå·ãå°æ°ç¹ï¼æ¯æå¤ä¸ªå段æåºï¼ |
| | | */ |
| | | public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; |
| | | public static final String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; |
| | | |
| | | /** |
| | | * æ£æ¥å符ï¼é²æ¢æ³¨å
¥ç»è¿ |
| | |
| | | public static boolean isValidOrderBySql(String value) { |
| | | return value.matches(SQL_PATTERN); |
| | | } |
| | | |
| | | /** |
| | | * SQLå
³é®åæ£æ¥ |
| | | */ |
| | | public static void filterKeyword(String value) { |
| | | if (StringUtils.isEmpty(value)) { |
| | | return; |
| | | } |
| | | String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|"); |
| | | for (String sqlKeyword : sqlKeywords) { |
| | | if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) { |
| | | throw new UtilException("åæ°åå¨SQL注å
¥é£é©"); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.xss; |
| | | |
| | | import javax.validation.Constraint; |
| | | import javax.validation.Payload; |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * èªå®ä¹xssæ ¡éªæ³¨è§£ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) |
| | | @Constraint(validatedBy = {XssValidator.class}) |
| | | public @interface Xss { |
| | | |
| | | String message() default "ä¸å
许任ä½èæ¬è¿è¡"; |
| | | |
| | | Class<?>[] groups() default {}; |
| | | |
| | | Class<? extends Payload>[] payload() default {}; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.xss; |
| | | |
| | | import cn.hutool.core.util.ReUtil; |
| | | import cn.hutool.http.HtmlUtil; |
| | | |
| | | import javax.validation.ConstraintValidator; |
| | | import javax.validation.ConstraintValidatorContext; |
| | | |
| | | /** |
| | | * èªå®ä¹xssæ ¡éªæ³¨è§£å®ç° |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class XssValidator implements ConstraintValidator<Xss, String> { |
| | | |
| | | @Override |
| | | public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { |
| | | return !ReUtil.contains(HtmlUtil.RE_HTML_MARK, value); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * æ°å¢æ¹éæ¹æ³ å¯å®ç¾æ¿ä»£ saveBatch ç§çº§æå
¥ä¸ä¸æ°æ® (对mysqlè´è·è¾å¤§) |
| | | * |
| | | * 3.5.0 çæ¬ å¢å rewriteBatchedStatements=true æ¹å¤çåæ° 使 MP åçæ¹å¤çå¯ä»¥è¾¾å°åæ ·çé度 |
| | | */ |
| | | @ApiOperation(value = "æ°å¢æ¹éæ¹æ³") |
| | | @PostMapping("/add") |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | // @DS("slave") |
| | | public AjaxResult<Void> add() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | |
| | | |
| | | /** |
| | | * æ°å¢ææ´æ° å¯å®ç¾æ¿ä»£ saveOrUpdateBatch 髿§è½ |
| | | * |
| | | * 3.5.0 çæ¬ å¢å rewriteBatchedStatements=true æ¹å¤çåæ° 使 MP åçæ¹å¤çå¯ä»¥è¾¾å°åæ ·çé度 |
| | | */ |
| | | @ApiOperation(value = "æ°å¢ææ´æ°æ¹éæ¹æ³") |
| | | @PostMapping("/addOrUpdate") |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | // @DS("slave") |
| | | public AjaxResult<Void> addOrUpdate() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | |
| | | */ |
| | | @ApiOperation(value = "å 餿¹éæ¹æ³") |
| | | @DeleteMapping() |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | // @DS("slave") |
| | | public AjaxResult<Void> remove() { |
| | | return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>() |
| | | .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0); |
| | |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | |
| | | @ApiOperation("æ¥è¯¢æµè¯å表å表") |
| | | @SaCheckPermission("demo:demo:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo) { |
| | | return iTestDemoService.queryPageList(bo); |
| | | public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) { |
| | | return iTestDemoService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("demo:demo:list") |
| | | @GetMapping("/page") |
| | | public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo) { |
| | | return iTestDemoService.customPageList(bo); |
| | | return iTestDemoService.customPageList(bo, pageQuery); |
| | | } |
| | | |
| | | @ApiOperation("导å
¥æµè¯-æ ¡éª") |
| | |
| | | package com.ruoyi.demo.domain.bo; |
| | | |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import javax.validation.constraints.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * æµè¯å表ä¸å¡å¯¹è±¡ test_demo |
| | |
| | | @ApiModelProperty("å¼") |
| | | @NotBlank(message = "å¼ä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private String value; |
| | | |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
| | |
| | | @NotBlank(message = "æ èç¹åä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private String treeName; |
| | | |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æµè¯å表Mapperæ¥å£ |
| | |
| | | */ |
| | | public interface TestDemoMapper extends BaseMapperPlus<TestDemo> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | Page<TestDemoVo> customPageList(@Param("page") Page<TestDemo> page, @Param("ew") Wrapper<TestDemo> wrapper); |
| | | |
| | | @Override |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | <P extends IPage<TestDemo>> P selectPage(P page, @Param(Constants.WRAPPER) Wrapper<TestDemo> queryWrapper); |
| | | |
| | | @Override |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | List<TestDemo> selectList(@Param(Constants.WRAPPER) Wrapper<TestDemo> queryWrapper); |
| | | |
| | | @Override |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | int updateById(@Param(Constants.ENTITY) TestDemo entity); |
| | | |
| | | @Override |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | int deleteBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList); |
| | | } |
| | |
| | | package com.ruoyi.demo.mapper; |
| | | |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | | |
| | |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | public interface TestTreeMapper extends BaseMapperPlus<TestTree> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.service; |
| | | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo); |
| | | TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * èªå®ä¹å页æ¥è¯¢ |
| | | */ |
| | | TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo); |
| | | TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | |
| | | package com.ruoyi.demo.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | |
| | | return getVoById(id); |
| | | } |
| | | |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo) { |
| | | PagePlus<TestDemo, TestDemoVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); |
| | | Page<TestDemoVo> result = pageVo(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹å页æ¥è¯¢ |
| | | */ |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo) { |
| | | Page<TestDemoVo> result = baseMapper.customPageList(PageUtils.buildPage(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | public TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); |
| | | Page<TestDemoVo> result = baseMapper.customPageList(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public List<TestDemoVo> queryList(TestDemoBo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | |
| | | |
| | | private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.apply(dataScope != null && StringUtils.isNotBlank(dataScope.toString()), |
| | | dataScope != null ? dataScope.toString() : null); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | //@DataSource(DataSourceType.SLAVE) // 忢ä»åºæ¥è¯¢ |
| | | // @DS("slave") // 忢ä»åºæ¥è¯¢ |
| | | @Service |
| | | public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService { |
| | | |
| | |
| | | return getVoById(id); |
| | | } |
| | | |
| | | // @DataSource(DataSourceType.SLAVE) // 忢ä»åºæ¥è¯¢ |
| | | @DataScope(isUser = true) |
| | | // @DS("slave") // 忢ä»åºæ¥è¯¢ |
| | | @Override |
| | | public List<TestTreeVo> queryList(TestTreeBo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | | LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo); |
| | | return listVo(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.apply(dataScope != null && StringUtils.isNotBlank(dataScope.toString()), |
| | | dataScope != null ? dataScope.toString() : null); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | |
| | | import de.codecentric.boot.admin.server.config.AdminServerProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | |
| | | */ |
| | | @Configuration |
| | | @EnableWebSecurity |
| | | @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, proxyTargetClass = true) |
| | | public class SecurityConfig extends WebSecurityConfigurerAdapter { |
| | | |
| | | private final String adminContextPath; |
| | |
| | | //æäºå¯¹ææéæèµäº§åç»å½é¡µé¢çå
Œ
±è®¿é®æéã |
| | | .antMatchers(adminContextPath + "/assets/**").permitAll() |
| | | .antMatchers(adminContextPath + "/login").permitAll() |
| | | .antMatchers("/actuator").anonymous() |
| | | .antMatchers("/actuator/**").anonymous() |
| | | .antMatchers("/actuator").permitAll() |
| | | .antMatchers("/actuator/**").permitAll() |
| | | //å¿
须对æ¯ä¸ªå
¶ä»è¯·æ±è¿è¡èº«ä»½éªè¯ |
| | | .anyRequest().authenticated().and() |
| | | //é
ç½®ç»å½å注é |
| | |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-resources-plugin</artifactId> |
| | | <version>2.6</version> |
| | | <configuration> |
| | | <nonFilteredFileExtensions> |
| | | <nonFilteredFileExtension>ttf</nonFilteredFileExtension> |
| | |
| | | import com.xxl.job.admin.core.util.FtlUtil; |
| | | import com.xxl.job.admin.core.util.I18nUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.servlet.AsyncHandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
| | | |
| | | import javax.servlet.http.Cookie; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | * @author xuxueli 2015-12-12 18:09:04 |
| | | */ |
| | | @Component |
| | | public class CookieInterceptor extends HandlerInterceptorAdapter { |
| | | public class CookieInterceptor implements AsyncHandlerInterceptor { |
| | | |
| | | @Override |
| | | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, |
| | |
| | | if (modelAndView != null) { |
| | | modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName())); |
| | | } |
| | | |
| | | super.postHandle(request, response, handler, modelAndView); |
| | | |
| | | AsyncHandlerInterceptor.super.postHandle(request, response, handler, modelAndView); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.xxl.job.admin.service.LoginService; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.method.HandlerMethod; |
| | | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
| | | import org.springframework.web.servlet.AsyncHandlerInterceptor; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | * @author xuxueli 2015-12-12 18:09:04 |
| | | */ |
| | | @Component |
| | | public class PermissionInterceptor extends HandlerInterceptorAdapter { |
| | | public class PermissionInterceptor implements AsyncHandlerInterceptor { |
| | | |
| | | @Resource |
| | | private LoginService loginService; |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | |
| | | |
| | | if (!(handler instanceof HandlerMethod)) { |
| | | return super.preHandle(request, response, handler); |
| | | return AsyncHandlerInterceptor.super.preHandle(request, response, handler); |
| | | } |
| | | |
| | | // if need login |
| | |
| | | request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser); |
| | | } |
| | | |
| | | return super.preHandle(request, response, handler); |
| | | return AsyncHandlerInterceptor.super.preHandle(request, response, handler); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <artifactId>druid-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- dynamic-datasource 夿°æ®æº--> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | <!-- sqlæ§è½åææä»¶ --> |
| | | <dependency> |
| | | <groupId>p6spy</groupId> |
| | | <artifactId>p6spy</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-actuator</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-client</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- ç³»ç»æ¨¡å--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-web-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * æ°æ®è¿æ»¤å¤ç |
| | | * |
| | | * @author Lion Li |
| | | * @deprecated 3.6.0 ç§»é¤ {@link com.ruoyi.framework.handler.PlusDataPermissionHandler} |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | @Deprecated |
| | | public class DataScopeAspect { |
| | | |
| | | /** |
| | |
| | | if (params instanceof BaseEntity) { |
| | | BaseEntity baseEntity = (BaseEntity) params; |
| | | baseEntity.getParams().put(DATA_SCOPE, sql); |
| | | } else { |
| | | Map<String, Object> invoke = ReflectUtils.invokeGetter(params, "params"); |
| | | invoke.put(DATA_SCOPE, sql); |
| | | } |
| | | } |
| | | } |
| | |
| | | * 夿°æ®æºå¤ç |
| | | * |
| | | * @author Lion Li |
| | | * @deprecated 3.6.0 ç§»é¤ ä½¿ç¨åçæ¹æ³å¤ç åè½æ´å
¨ |
| | | */ |
| | | @Aspect |
| | | @Order(-500) |
| | | @Component |
| | | @Deprecated |
| | | public class DataSourceAspect { |
| | | |
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)" |
| | |
| | | stringBuffer.append(ServletUtils.getClientIP()).append("-"); |
| | | } else if (rateLimiter.limitType() == LimitType.CLUSTER){ |
| | | // è·å客æ·ç«¯å®ä¾id |
| | | stringBuffer.append(RedisUtils.getClientId()).append("-"); |
| | | stringBuffer.append(RedisUtils.getClient().getId()).append("-"); |
| | | } |
| | | MethodSignature signature = (MethodSignature) point.getSignature(); |
| | | Method method = signature.getMethod(); |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import cn.hutool.core.net.NetUtil; |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; |
| | | import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; |
| | | import com.baomidou.mybatisplus.core.injector.ISqlInjector; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.ruoyi.common.core.mybatisplus.methods.InsertAll; |
| | | import com.ruoyi.framework.handler.CreateAndUpdateMetaObjectHandler; |
| | | import com.ruoyi.framework.interceptor.PlusDataPermissionInterceptor; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | // æ°æ®æéå¤ç |
| | | interceptor.addInnerInterceptor(dataPermissionInterceptor()); |
| | | // å页æä»¶ |
| | | interceptor.addInnerInterceptor(paginationInnerInterceptor()); |
| | | // ä¹è§éæä»¶ |
| | | interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); |
| | | return interceptor; |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®æéæ¦æªå¨ |
| | | */ |
| | | public PlusDataPermissionInterceptor dataPermissionInterceptor() { |
| | | return new PlusDataPermissionInterceptor(); |
| | | } |
| | | |
| | | /** |
| | | * å页æä»¶ï¼èªå¨è¯å«æ°æ®åºç±»å |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * 使ç¨ç½å¡ä¿¡æ¯ç»å®éªè±çæå¨ |
| | | * 鲿¢é群éªè±IDéå¤ |
| | | */ |
| | | @Bean |
| | | public IdentifierGenerator idGenerator() { |
| | | return new DefaultIdentifierGenerator(NetUtil.getLocalhost()); |
| | | } |
| | | |
| | | /** |
| | | * PaginationInnerInterceptor å页æä»¶ï¼èªå¨è¯å«æ°æ®åºç±»å |
| | | * https://baomidou.com/guide/interceptor-pagination.html |
| | | * https://baomidou.com/pages/97710a/ |
| | | * OptimisticLockerInnerInterceptor ä¹è§éæä»¶ |
| | | * https://baomidou.com/guide/interceptor-optimistic-locker.html |
| | | * https://baomidou.com/pages/0d93c0/ |
| | | * MetaObjectHandler å
å¯¹è±¡åæ®µå¡«å
æ§å¶å¨ |
| | | * https://baomidou.com/guide/auto-fill-metainfo.html |
| | | * https://baomidou.com/pages/4c6bcf/ |
| | | * ISqlInjector sql注å
¥å¨ |
| | | * https://baomidou.com/guide/sql-injector.html |
| | | * https://baomidou.com/pages/42ea4a/ |
| | | * BlockAttackInnerInterceptor 妿æ¯å¯¹å
¨è¡¨çå é¤ææ´æ°æä½ï¼å°±ä¼ç»æ¢è¯¥æä½ |
| | | * https://baomidou.com/guide/interceptor-block-attack.html |
| | | * https://baomidou.com/pages/f9a237/ |
| | | * IllegalSQLInnerInterceptor sqlæ§è½è§èæä»¶(åå¾SQLæ¦æª) |
| | | * IdentifierGenerator èªå®ä¹ä¸»é®çç¥ |
| | | * https://baomidou.com/guide/id-generator.html |
| | | * https://baomidou.com/pages/568eb2/ |
| | | * TenantLineInnerInterceptor å¤ç§æ·æä»¶ |
| | | * https://baomidou.com/guide/interceptor-tenant-line.html |
| | | * https://baomidou.com/pages/aef2f2/ |
| | | * DynamicTableNameInnerInterceptor å¨æè¡¨åæä»¶ |
| | | * https://baomidou.com/guide/interceptor-dynamic-table-name.html |
| | | * https://baomidou.com/pages/2a45ff/ |
| | | */ |
| | | |
| | | } |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * redisé
ç½® |
| | |
| | | @EnableCaching |
| | | public class RedisConfig extends CachingConfigurerSupport { |
| | | |
| | | private static final String REDIS_PROTOCOL_PREFIX = "redis://"; |
| | | private static final String REDISS_PROTOCOL_PREFIX = "rediss://"; |
| | | private static final String REDIS_PROTOCOL_PREFIX = "redis://"; |
| | | private static final String REDISS_PROTOCOL_PREFIX = "rediss://"; |
| | | |
| | | @Autowired |
| | | private RedisProperties redisProperties; |
| | | @Autowired |
| | | private RedisProperties redisProperties; |
| | | |
| | | @Autowired |
| | | private RedissonProperties redissonProperties; |
| | | @Autowired |
| | | private RedissonProperties redissonProperties; |
| | | |
| | | @Bean(destroyMethod = "shutdown") |
| | | @ConditionalOnMissingBean(RedissonClient.class) |
| | | public RedissonClient redisson() throws IOException { |
| | | String prefix = REDIS_PROTOCOL_PREFIX; |
| | | if (redisProperties.isSsl()) { |
| | | prefix = REDISS_PROTOCOL_PREFIX; |
| | | } |
| | | Config config = new Config(); |
| | | config.setThreads(redissonProperties.getThreads()) |
| | | .setNettyThreads(redissonProperties.getNettyThreads()) |
| | | .setCodec(JsonJacksonCodec.INSTANCE) |
| | | .setTransportMode(redissonProperties.getTransportMode()); |
| | | @Bean(destroyMethod = "shutdown") |
| | | @ConditionalOnMissingBean(RedissonClient.class) |
| | | public RedissonClient redisson() throws IOException { |
| | | String prefix = REDIS_PROTOCOL_PREFIX; |
| | | if (redisProperties.isSsl()) { |
| | | prefix = REDISS_PROTOCOL_PREFIX; |
| | | } |
| | | Config config = new Config(); |
| | | config.setThreads(redissonProperties.getThreads()) |
| | | .setNettyThreads(redissonProperties.getNettyThreads()) |
| | | .setCodec(JsonJacksonCodec.INSTANCE) |
| | | .setTransportMode(redissonProperties.getTransportMode()); |
| | | |
| | | RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig(); |
| | | if (ObjectUtil.isNotNull(singleServerConfig)) { |
| | | // 使ç¨åæºæ¨¡å¼ |
| | | config.useSingleServer() |
| | | .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) |
| | | .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) |
| | | .setDatabase(redisProperties.getDatabase()) |
| | | .setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) |
| | | .setTimeout(singleServerConfig.getTimeout()) |
| | | .setRetryAttempts(singleServerConfig.getRetryAttempts()) |
| | | .setRetryInterval(singleServerConfig.getRetryInterval()) |
| | | .setSubscriptionsPerConnection(singleServerConfig.getSubscriptionsPerConnection()) |
| | | .setClientName(singleServerConfig.getClientName()) |
| | | .setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout()) |
| | | .setSubscriptionConnectionMinimumIdleSize(singleServerConfig.getSubscriptionConnectionMinimumIdleSize()) |
| | | .setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize()) |
| | | .setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize()) |
| | | .setConnectionPoolSize(singleServerConfig.getConnectionPoolSize()) |
| | | .setDnsMonitoringInterval(singleServerConfig.getDnsMonitoringInterval()); |
| | | } |
| | | // é群é
ç½®æ¹å¼ åè䏿¹æ³¨é |
| | | RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig(); |
| | | if (ObjectUtil.isNotNull(clusterServersConfig)) { |
| | | // 使ç¨éç¾¤æ¨¡å¼ |
| | | config.useClusterServers() |
| | | .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) |
| | | .setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) |
| | | .setTimeout(clusterServersConfig.getTimeout()) |
| | | .setRetryAttempts(clusterServersConfig.getRetryAttempts()) |
| | | .setRetryInterval(clusterServersConfig.getRetryInterval()) |
| | | .setSubscriptionsPerConnection(clusterServersConfig.getSubscriptionsPerConnection()) |
| | | .setClientName(clusterServersConfig.getClientName()) |
| | | .setIdleConnectionTimeout(clusterServersConfig.getIdleConnectionTimeout()) |
| | | .setPingConnectionInterval(clusterServersConfig.getPingConnectionInterval()) |
| | | .setSubscriptionConnectionMinimumIdleSize(clusterServersConfig.getSubscriptionConnectionMinimumIdleSize()) |
| | | .setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize()) |
| | | .setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize()) |
| | | .setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize()) |
| | | .setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize()) |
| | | .setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize()) |
| | | .setDnsMonitoringInterval(clusterServersConfig.getDnsMonitoringInterval()) |
| | | .setFailedSlaveReconnectionInterval(clusterServersConfig.getFailedSlaveReconnectionInterval()) |
| | | .setScanInterval(clusterServersConfig.getScanInterval()) |
| | | .setReadMode(clusterServersConfig.getReadMode()) |
| | | .setSubscriptionMode(clusterServersConfig.getSubscriptionMode()) |
| | | .setNodeAddresses(redisProperties.getCluster().getNodes()); |
| | | } |
| | | RedissonClient redissonClient = Redisson.create(config); |
| | | log.info("åå§å redis é
ç½®"); |
| | | return redissonClient; |
| | | } |
| | | RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig(); |
| | | if (ObjectUtil.isNotNull(singleServerConfig)) { |
| | | // 使ç¨åæºæ¨¡å¼ |
| | | config.useSingleServer() |
| | | .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) |
| | | .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) |
| | | .setDatabase(redisProperties.getDatabase()) |
| | | .setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) |
| | | .setTimeout(singleServerConfig.getTimeout()) |
| | | .setRetryAttempts(singleServerConfig.getRetryAttempts()) |
| | | .setRetryInterval(singleServerConfig.getRetryInterval()) |
| | | .setSubscriptionsPerConnection(singleServerConfig.getSubscriptionsPerConnection()) |
| | | .setClientName(singleServerConfig.getClientName()) |
| | | .setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout()) |
| | | .setSubscriptionConnectionMinimumIdleSize(singleServerConfig.getSubscriptionConnectionMinimumIdleSize()) |
| | | .setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize()) |
| | | .setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize()) |
| | | .setConnectionPoolSize(singleServerConfig.getConnectionPoolSize()) |
| | | .setDnsMonitoringInterval(singleServerConfig.getDnsMonitoringInterval()); |
| | | } |
| | | // é群é
ç½®æ¹å¼ åè䏿¹æ³¨é |
| | | RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig(); |
| | | if (ObjectUtil.isNotNull(clusterServersConfig)) { |
| | | // 使ç¨éç¾¤æ¨¡å¼ |
| | | String finalPrefix = prefix; |
| | | List<String> nodes = redisProperties.getCluster().getNodes() |
| | | .stream() |
| | | .map(node -> finalPrefix + node) |
| | | .collect(Collectors.toList()); |
| | | |
| | | /** |
| | | * æ´åspring-cache |
| | | */ |
| | | @Bean |
| | | public CacheManager cacheManager(RedissonClient redissonClient) { |
| | | List<RedissonProperties.CacheGroup> cacheGroup = redissonProperties.getCacheGroup(); |
| | | Map<String, CacheConfig> config = new HashMap<>(); |
| | | for (RedissonProperties.CacheGroup group : cacheGroup) { |
| | | CacheConfig cacheConfig = new CacheConfig(group.getTtl(), group.getMaxIdleTime()); |
| | | cacheConfig.setMaxSize(group.getMaxSize()); |
| | | config.put(group.getGroupId(), cacheConfig); |
| | | } |
| | | return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE); |
| | | } |
| | | config.useClusterServers() |
| | | .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) |
| | | .setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) |
| | | .setTimeout(clusterServersConfig.getTimeout()) |
| | | .setRetryAttempts(clusterServersConfig.getRetryAttempts()) |
| | | .setRetryInterval(clusterServersConfig.getRetryInterval()) |
| | | .setSubscriptionsPerConnection(clusterServersConfig.getSubscriptionsPerConnection()) |
| | | .setClientName(clusterServersConfig.getClientName()) |
| | | .setIdleConnectionTimeout(clusterServersConfig.getIdleConnectionTimeout()) |
| | | .setPingConnectionInterval(clusterServersConfig.getPingConnectionInterval()) |
| | | .setSubscriptionConnectionMinimumIdleSize(clusterServersConfig.getSubscriptionConnectionMinimumIdleSize()) |
| | | .setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize()) |
| | | .setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize()) |
| | | .setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize()) |
| | | .setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize()) |
| | | .setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize()) |
| | | .setDnsMonitoringInterval(clusterServersConfig.getDnsMonitoringInterval()) |
| | | .setFailedSlaveReconnectionInterval(clusterServersConfig.getFailedSlaveReconnectionInterval()) |
| | | .setScanInterval(clusterServersConfig.getScanInterval()) |
| | | .setReadMode(clusterServersConfig.getReadMode()) |
| | | .setSubscriptionMode(clusterServersConfig.getSubscriptionMode()) |
| | | .setNodeAddresses(nodes); |
| | | } |
| | | RedissonClient redissonClient = Redisson.create(config); |
| | | log.info("åå§å redis é
ç½®"); |
| | | return redissonClient; |
| | | } |
| | | |
| | | /** |
| | | * redisé群é
ç½® yml |
| | | * |
| | | * --- # redis é群é
ç½®(åæºä¸é群åªè½å¼å¯ä¸ä¸ªå¦ä¸ä¸ªéè¦æ³¨éæ) |
| | | * spring: |
| | | * redis: |
| | | * cluster: |
| | | * nodes: |
| | | * - 192.168.0.100:6379 |
| | | * - 192.168.0.101:6379 |
| | | * - 192.168.0.102:6379 |
| | | * # å¯ç |
| | | * password: |
| | | * # è¿æ¥è¶
æ¶æ¶é´ |
| | | * timeout: 10s |
| | | * # æ¯å¦å¼å¯ssl |
| | | * ssl: false |
| | | * |
| | | * redisson: |
| | | * # çº¿ç¨æ± æ°é |
| | | * threads: 16 |
| | | * # Nettyçº¿ç¨æ± æ°é |
| | | * nettyThreads: 32 |
| | | * # ä¼ è¾æ¨¡å¼ |
| | | * transportMode: "NIO" |
| | | * # é群é
ç½® |
| | | * clusterServersConfig: |
| | | * # 客æ·ç«¯åç§° |
| | | * clientName: ${ruoyi.name} |
| | | * # masteræå°ç©ºé²è¿æ¥æ° |
| | | * masterConnectionMinimumIdleSize: 32 |
| | | * # masterè¿æ¥æ± å¤§å° |
| | | * masterConnectionPoolSize: 64 |
| | | * # slaveæå°ç©ºé²è¿æ¥æ° |
| | | * slaveConnectionMinimumIdleSize: 32 |
| | | * # slaveè¿æ¥æ± å¤§å° |
| | | * slaveConnectionPoolSize: 64 |
| | | * # è¿æ¥ç©ºé²è¶
æ¶ï¼åä½ï¼æ¯«ç§ |
| | | * idleConnectionTimeout: 10000 |
| | | * # pingè¿æ¥é´é |
| | | * pingConnectionInterval: 1000 |
| | | * # å½ä»¤çå¾
è¶
æ¶ï¼åä½ï¼æ¯«ç§ |
| | | * timeout: 3000 |
| | | * # 妿å°è¯å¨æ¤éå¶ä¹å
åéæåï¼åå¼å§å¯ç¨ timeout 计æ¶ã |
| | | * retryAttempts: 3 |
| | | * # å½ä»¤éè¯åéæ¶é´é´éï¼åä½ï¼æ¯«ç§ |
| | | * retryInterval: 1500 |
| | | * # ä»å¯ç¨æå¡å¨çå
é¨åè¡¨ä¸æé¤ Redis Slave éæ°è¿æ¥å°è¯çé´éã |
| | | * failedSlaveReconnectionInterval: 3000 |
| | | * # åå¸å订é
è¿æ¥æ± æå°ç©ºé²è¿æ¥æ° |
| | | * subscriptionConnectionMinimumIdleSize: 1 |
| | | * # åå¸å订é
è¿æ¥æ± å¤§å° |
| | | * subscriptionConnectionPoolSize: 50 |
| | | * # åä¸ªè¿æ¥æå¤§è®¢é
æ°é |
| | | * subscriptionsPerConnection: 5 |
| | | * # æ«æé´é |
| | | * scanInterval: 1000 |
| | | * # DNSçæµæ¶é´é´éï¼åä½ï¼æ¯«ç§ |
| | | * dnsMonitoringInterval: 5000 |
| | | * # è¯»åæ¨¡å¼ |
| | | * readMode: "SLAVE" |
| | | * # 订é
æ¨¡å¼ |
| | | * subscriptionMode: "MASTER" |
| | | */ |
| | | /** |
| | | * æ´åspring-cache |
| | | */ |
| | | @Bean |
| | | public CacheManager cacheManager(RedissonClient redissonClient) { |
| | | List<RedissonProperties.CacheGroup> cacheGroup = redissonProperties.getCacheGroup(); |
| | | Map<String, CacheConfig> config = new HashMap<>(); |
| | | for (RedissonProperties.CacheGroup group : cacheGroup) { |
| | | CacheConfig cacheConfig = new CacheConfig(group.getTtl(), group.getMaxIdleTime()); |
| | | cacheConfig.setMaxSize(group.getMaxSize()); |
| | | config.put(group.getGroupId(), cacheConfig); |
| | | } |
| | | return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE); |
| | | } |
| | | |
| | | /** |
| | | * redisé群é
ç½® yml |
| | | * |
| | | * --- # redis é群é
ç½®(åæºä¸é群åªè½å¼å¯ä¸ä¸ªå¦ä¸ä¸ªéè¦æ³¨éæ) |
| | | * spring: |
| | | * redis: |
| | | * cluster: |
| | | * nodes: |
| | | * - 192.168.0.100:6379 |
| | | * - 192.168.0.101:6379 |
| | | * - 192.168.0.102:6379 |
| | | * # å¯ç |
| | | * password: |
| | | * # è¿æ¥è¶
æ¶æ¶é´ |
| | | * timeout: 10s |
| | | * # æ¯å¦å¼å¯ssl |
| | | * ssl: false |
| | | * |
| | | * redisson: |
| | | * # çº¿ç¨æ± æ°é |
| | | * threads: 16 |
| | | * # Nettyçº¿ç¨æ± æ°é |
| | | * nettyThreads: 32 |
| | | * # ä¼ è¾æ¨¡å¼ |
| | | * transportMode: "NIO" |
| | | * # é群é
ç½® |
| | | * clusterServersConfig: |
| | | * # 客æ·ç«¯åç§° |
| | | * clientName: ${ruoyi.name} |
| | | * # masteræå°ç©ºé²è¿æ¥æ° |
| | | * masterConnectionMinimumIdleSize: 32 |
| | | * # masterè¿æ¥æ± å¤§å° |
| | | * masterConnectionPoolSize: 64 |
| | | * # slaveæå°ç©ºé²è¿æ¥æ° |
| | | * slaveConnectionMinimumIdleSize: 32 |
| | | * # slaveè¿æ¥æ± å¤§å° |
| | | * slaveConnectionPoolSize: 64 |
| | | * # è¿æ¥ç©ºé²è¶
æ¶ï¼åä½ï¼æ¯«ç§ |
| | | * idleConnectionTimeout: 10000 |
| | | * # pingè¿æ¥é´é |
| | | * pingConnectionInterval: 1000 |
| | | * # å½ä»¤çå¾
è¶
æ¶ï¼åä½ï¼æ¯«ç§ |
| | | * timeout: 3000 |
| | | * # 妿å°è¯å¨æ¤éå¶ä¹å
åéæåï¼åå¼å§å¯ç¨ timeout 计æ¶ã |
| | | * retryAttempts: 3 |
| | | * # å½ä»¤éè¯åéæ¶é´é´éï¼åä½ï¼æ¯«ç§ |
| | | * retryInterval: 1500 |
| | | * # ä»å¯ç¨æå¡å¨çå
é¨åè¡¨ä¸æé¤ Redis Slave éæ°è¿æ¥å°è¯çé´éã |
| | | * failedSlaveReconnectionInterval: 3000 |
| | | * # åå¸å订é
è¿æ¥æ± æå°ç©ºé²è¿æ¥æ° |
| | | * subscriptionConnectionMinimumIdleSize: 1 |
| | | * # åå¸å订é
è¿æ¥æ± å¤§å° |
| | | * subscriptionConnectionPoolSize: 50 |
| | | * # åä¸ªè¿æ¥æå¤§è®¢é
æ°é |
| | | * subscriptionsPerConnection: 5 |
| | | * # æ«æé´é |
| | | * scanInterval: 1000 |
| | | * # DNSçæµæ¶é´é´éï¼åä½ï¼æ¯«ç§ |
| | | * dnsMonitoringInterval: 5000 |
| | | * # è¯»åæ¨¡å¼ |
| | | * readMode: "SLAVE" |
| | | * # 订é
æ¨¡å¼ |
| | | * subscriptionMode: "MASTER" |
| | | */ |
| | | |
| | | } |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import com.ruoyi.framework.Interceptor.PlusWebInvokeTimeInterceptor; |
| | | import com.ruoyi.framework.interceptor.PlusWebInvokeTimeInterceptor; |
| | | import com.yomahub.tlog.web.interceptor.TLogWebInterceptor; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import com.yomahub.tlog.core.aop.AspectLogAop; |
| | | import com.yomahub.tlog.spring.TLogPropertyInit; |
| | | import com.yomahub.tlog.spring.TLogSpringAware; |
| | | import com.yomahub.tlog.springboot.property.TLogProperty; |
| | | import org.springframework.context.annotation.Bean; |
| | | import com.yomahub.tlog.springboot.TLogWebAutoConfiguration; |
| | | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.core.annotation.Order; |
| | | |
| | | /** |
| | | * æ´å TLog æ¡æ¶é
ç½® |
| | |
| | | * @author Lion Li |
| | | * @since 3.3.0 |
| | | */ |
| | | @Order(-999) |
| | | @Configuration |
| | | @Import(TLogProperty.class) |
| | | // æé¤ web èªå¨é
ç½® èªå®ä¹å®ç° |
| | | @EnableAutoConfiguration(exclude = TLogWebAutoConfiguration.class) |
| | | public class TLogConfig { |
| | | |
| | | @Bean |
| | | public TLogPropertyInit tLogPropertyInit(TLogProperty tLogProperty) { |
| | | TLogPropertyInit tLogPropertyInit = new TLogPropertyInit(); |
| | | tLogPropertyInit.setPattern(tLogProperty.getPattern()); |
| | | tLogPropertyInit.setEnableInvokeTimePrint(tLogProperty.enableInvokeTimePrint()); |
| | | tLogPropertyInit.setIdGenerator(tLogProperty.getIdGenerator()); |
| | | tLogPropertyInit.setMdcEnable(tLogProperty.getMdcEnable()); |
| | | return tLogPropertyInit; |
| | | } |
| | | |
| | | @Bean |
| | | public TLogSpringAware tLogSpringAware(){ |
| | | return new TLogSpringAware(); |
| | | } |
| | | |
| | | @Bean |
| | | public AspectLogAop aspectLogAop() { |
| | | return new AspectLogAop(); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.handler; |
| | | |
| | | import cn.hutool.core.annotation.AnnotationUtil; |
| | | import cn.hutool.core.collection.ConcurrentHashSet; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ClassUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.service.UserService; |
| | | import com.ruoyi.common.enums.DataScopeType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.helper.DataPermissionHelper; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import net.sf.jsqlparser.JSQLParserException; |
| | | import net.sf.jsqlparser.expression.Expression; |
| | | import net.sf.jsqlparser.expression.Parenthesis; |
| | | import net.sf.jsqlparser.expression.operators.conditional.AndExpression; |
| | | import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
| | | import org.springframework.context.expression.BeanFactoryResolver; |
| | | import org.springframework.expression.BeanResolver; |
| | | import org.springframework.expression.ExpressionParser; |
| | | import org.springframework.expression.ParserContext; |
| | | import org.springframework.expression.common.TemplateParserContext; |
| | | import org.springframework.expression.spel.standard.SpelExpressionParser; |
| | | import org.springframework.expression.spel.support.StandardEvaluationContext; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * æ°æ®æéè¿æ»¤ |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.5.0 |
| | | */ |
| | | @Slf4j |
| | | public class PlusDataPermissionHandler { |
| | | |
| | | /** |
| | | * æ¹æ³æç±»(åç§°) ä¸ æ³¨è§£çæ å°å
³ç³»ç¼å |
| | | */ |
| | | private final Map<String, DataPermission> dataPermissionCacheMap = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * æ ææ³¨è§£æ¹æ³ç¼åç¨äºå¿«éè¿å |
| | | */ |
| | | private final Set<String> inavlidCacheSet = new ConcurrentHashSet<>(); |
| | | |
| | | /** |
| | | * spel è§£æå¨ |
| | | */ |
| | | private final ExpressionParser parser = new SpelExpressionParser(); |
| | | private final ParserContext parserContext = new TemplateParserContext(); |
| | | /** |
| | | * beanè§£æå¨ ç¨äºå¤ç spel 表达å¼ä¸å¯¹ bean çè°ç¨ |
| | | */ |
| | | private final BeanResolver beanResolver = new BeanFactoryResolver(SpringUtils.getBeanFactory()); |
| | | |
| | | |
| | | public Expression getSqlSegment(Expression where, String mappedStatementId, boolean isSelect) { |
| | | DataColumn[] dataColumns = findAnnotation(mappedStatementId); |
| | | if (ArrayUtil.isEmpty(dataColumns)) { |
| | | inavlidCacheSet.add(mappedStatementId); |
| | | return where; |
| | | } |
| | | SysUser currentUser = DataPermissionHelper.getVariable("user"); |
| | | if (ObjectUtil.isNull(currentUser)) { |
| | | currentUser = SpringUtils.getBean(UserService.class).selectUserById(SecurityUtils.getUserId()); |
| | | DataPermissionHelper.setVariable("user", currentUser); |
| | | } |
| | | // 妿æ¯è¶
级管çåï¼åä¸è¿æ»¤æ°æ® |
| | | if (ObjectUtil.isNull(currentUser) || currentUser.isAdmin()) { |
| | | return where; |
| | | } |
| | | String dataFilterSql = buildDataFilter(dataColumns, isSelect); |
| | | if (StringUtils.isBlank(dataFilterSql)) { |
| | | return where; |
| | | } |
| | | try { |
| | | Expression expression = CCJSqlParserUtil.parseExpression(dataFilterSql); |
| | | // æ°æ®æé使ç¨åç¬çæ¬å· 鲿¢ä¸å
¶ä»æ¡ä»¶å²çª |
| | | Parenthesis parenthesis = new Parenthesis(expression); |
| | | if (ObjectUtil.isNotNull(where)) { |
| | | return new AndExpression(where, parenthesis); |
| | | } else { |
| | | return parenthesis; |
| | | } |
| | | } catch (JSQLParserException e) { |
| | | throw new ServiceException("æ°æ®æéè§£æå¼å¸¸ => " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æé æ°æ®è¿æ»¤sql |
| | | */ |
| | | private String buildDataFilter(DataColumn[] dataColumns, boolean isSelect) { |
| | | StringBuilder sqlString = new StringBuilder(); |
| | | // æ´æ°æå é¤éæ»¡è¶³æææ¡ä»¶ |
| | | String joinStr = isSelect ? " OR " : " AND "; |
| | | SysUser user = DataPermissionHelper.getVariable("user"); |
| | | StandardEvaluationContext context = new StandardEvaluationContext(); |
| | | context.setBeanResolver(beanResolver); |
| | | DataPermissionHelper.getContext().forEach(context::setVariable); |
| | | for (SysRole role : user.getRoles()) { |
| | | user.setRoleId(role.getRoleId()); |
| | | // è·åè§è²æéæ³å |
| | | DataScopeType type = DataScopeType.findCode(role.getDataScope()); |
| | | if (ObjectUtil.isNull(type)) { |
| | | throw new ServiceException("è§è²æ°æ®èå´å¼å¸¸ => " + role.getDataScope()); |
| | | } |
| | | // å
¨é¨æ°æ®æéç´æ¥è¿å |
| | | if (type == DataScopeType.ALL) { |
| | | return ""; |
| | | } |
| | | boolean isSuccess = false; |
| | | for (DataColumn dataColumn : dataColumns) { |
| | | // ä¸å
å« key åé åä¸å¤ç |
| | | if (!StringUtils.contains(type.getSqlTemplate(), "#" + dataColumn.key())) { |
| | | continue; |
| | | } |
| | | // 设置注解åé key 为表达å¼åé value 为åéå¼ |
| | | context.setVariable(dataColumn.key(), dataColumn.value()); |
| | | |
| | | // è§£æsql模æ¿å¹¶å¡«å
|
| | | String sql = parser.parseExpression(type.getSqlTemplate(), parserContext).getValue(context, String.class); |
| | | sqlString.append(joinStr).append(sql); |
| | | isSuccess = true; |
| | | } |
| | | // æªå¤çæååå¡«å
å
åºæ¹æ¡ |
| | | if (!isSuccess) { |
| | | sqlString.append(joinStr).append(type.getElseSql()); |
| | | } |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(sqlString.toString())) { |
| | | return sqlString.substring(joinStr.length()); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private DataColumn[] findAnnotation(String mappedStatementId) { |
| | | StringBuilder sb = new StringBuilder(mappedStatementId); |
| | | int index = sb.lastIndexOf("."); |
| | | String clazzName = sb.substring(0, index); |
| | | String methodName = sb.substring(index + 1, sb.length()); |
| | | Class<?> clazz = ClassUtil.loadClass(clazzName); |
| | | List<Method> methods = Arrays.stream(ClassUtil.getDeclaredMethods(clazz)) |
| | | .filter(method -> method.getName().equals(methodName)).collect(Collectors.toList()); |
| | | DataPermission dataPermission; |
| | | // è·åæ¹æ³æ³¨è§£ |
| | | for (Method method : methods) { |
| | | dataPermission = dataPermissionCacheMap.get(method.getName()); |
| | | if (ObjectUtil.isNotNull(dataPermission)) { |
| | | return dataPermission.value(); |
| | | } |
| | | if (AnnotationUtil.hasAnnotation(method, DataPermission.class)) { |
| | | dataPermission = AnnotationUtil.getAnnotation(method, DataPermission.class); |
| | | dataPermissionCacheMap.put(method.getName(), dataPermission); |
| | | return dataPermission.value(); |
| | | } |
| | | } |
| | | dataPermission = dataPermissionCacheMap.get(clazz.getName()); |
| | | if (ObjectUtil.isNotNull(dataPermission)) { |
| | | return dataPermission.value(); |
| | | } |
| | | // è·å类注解 |
| | | if (AnnotationUtil.hasAnnotation(clazz, DataPermission.class)) { |
| | | dataPermission = AnnotationUtil.getAnnotation(clazz, DataPermission.class); |
| | | dataPermissionCacheMap.put(clazz.getName(), dataPermission); |
| | | return dataPermission.value(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºæ ææ¹æ³ æ æ°æ®æé |
| | | */ |
| | | public boolean isInvalid(String mappedStatementId) { |
| | | return inavlidCacheSet.contains(mappedStatementId); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.interceptor; |
| | | |
| | | import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper; |
| | | import com.baomidou.mybatisplus.core.toolkit.PluginUtils; |
| | | import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; |
| | | import com.ruoyi.framework.handler.PlusDataPermissionHandler; |
| | | import net.sf.jsqlparser.expression.Expression; |
| | | import net.sf.jsqlparser.statement.delete.Delete; |
| | | import net.sf.jsqlparser.statement.select.PlainSelect; |
| | | import net.sf.jsqlparser.statement.select.Select; |
| | | import net.sf.jsqlparser.statement.select.SelectBody; |
| | | import net.sf.jsqlparser.statement.select.SetOperationList; |
| | | import net.sf.jsqlparser.statement.update.Update; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.executor.statement.StatementHandler; |
| | | import org.apache.ibatis.mapping.BoundSql; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlCommandType; |
| | | import org.apache.ibatis.session.ResultHandler; |
| | | import org.apache.ibatis.session.RowBounds; |
| | | |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æ°æ®æéæ¦æªå¨ |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.5.0 |
| | | */ |
| | | public class PlusDataPermissionInterceptor extends JsqlParserSupport implements InnerInterceptor { |
| | | |
| | | private final PlusDataPermissionHandler dataPermissionHandler = new PlusDataPermissionHandler(); |
| | | |
| | | @Override |
| | | public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { |
| | | // æ£æ¥å¿½ç¥æ³¨è§£ |
| | | if (InterceptorIgnoreHelper.willIgnoreDataPermission(ms.getId())) { |
| | | return; |
| | | } |
| | | // æ£æ¥æ¯å¦æ æ æ æ°æ®æé注解 |
| | | if (dataPermissionHandler.isInvalid(ms.getId())) { |
| | | return; |
| | | } |
| | | // è§£æ sql åé
å¯¹åºæ¹æ³ |
| | | PluginUtils.MPBoundSql mpBs = PluginUtils.mpBoundSql(boundSql); |
| | | mpBs.sql(parserSingle(mpBs.sql(), ms.getId())); |
| | | } |
| | | |
| | | @Override |
| | | public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) { |
| | | PluginUtils.MPStatementHandler mpSh = PluginUtils.mpStatementHandler(sh); |
| | | MappedStatement ms = mpSh.mappedStatement(); |
| | | SqlCommandType sct = ms.getSqlCommandType(); |
| | | if (sct == SqlCommandType.UPDATE || sct == SqlCommandType.DELETE) { |
| | | if (InterceptorIgnoreHelper.willIgnoreDataPermission(ms.getId())) { |
| | | return; |
| | | } |
| | | PluginUtils.MPBoundSql mpBs = mpSh.mPBoundSql(); |
| | | mpBs.sql(parserMulti(mpBs.sql(), ms.getId())); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void processSelect(Select select, int index, String sql, Object obj) { |
| | | SelectBody selectBody = select.getSelectBody(); |
| | | if (selectBody instanceof PlainSelect) { |
| | | this.setWhere((PlainSelect) selectBody, (String) obj); |
| | | } else if (selectBody instanceof SetOperationList) { |
| | | SetOperationList setOperationList = (SetOperationList) selectBody; |
| | | List<SelectBody> selectBodyList = setOperationList.getSelects(); |
| | | selectBodyList.forEach(s -> this.setWhere((PlainSelect) s, (String) obj)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void processUpdate(Update update, int index, String sql, Object obj) { |
| | | Expression sqlSegment = dataPermissionHandler.getSqlSegment(update.getWhere(), (String) obj, false); |
| | | if (null != sqlSegment) { |
| | | update.setWhere(sqlSegment); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void processDelete(Delete delete, int index, String sql, Object obj) { |
| | | Expression sqlSegment = dataPermissionHandler.getSqlSegment(delete.getWhere(), (String) obj, false); |
| | | if (null != sqlSegment) { |
| | | delete.setWhere(sqlSegment); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置 where æ¡ä»¶ |
| | | * |
| | | * @param plainSelect æ¥è¯¢å¯¹è±¡ |
| | | * @param mappedStatementId æ§è¡æ¹æ³id |
| | | */ |
| | | protected void setWhere(PlainSelect plainSelect, String mappedStatementId) { |
| | | Expression sqlSegment = dataPermissionHandler.getSqlSegment(plainSelect.getWhere(), mappedStatementId, true); |
| | | if (null != sqlSegment) { |
| | | plainSelect.setWhere(sqlSegment); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.interceptor; |
| | | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.map.MapUtil; |
| | | import com.alibaba.ttl.TransmittableThreadLocal; |
| | | import com.ruoyi.common.filter.RepeatedlyRequestWrapper; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.time.StopWatch; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * webçè°ç¨æ¶é´ç»è®¡æ¦æªå¨ |
| | | * devç¯å¢ææ |
| | | * |
| | | * @author Lion Li |
| | | * @since 3.3.0 |
| | | */ |
| | | @Slf4j |
| | | public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor { |
| | | |
| | | private final TransmittableThreadLocal<StopWatch> invokeTimeTL = new TransmittableThreadLocal<>(); |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | if (!"prod".equals(SpringUtils.getActiveProfile())) { |
| | | String url = request.getMethod() + " " + request.getRequestURI(); |
| | | |
| | | // æå°è¯·æ±åæ° |
| | | if (isJsonRequest(request)) { |
| | | String jsonParam = ""; |
| | | if (request instanceof RepeatedlyRequestWrapper) { |
| | | BufferedReader reader = request.getReader(); |
| | | jsonParam = IoUtil.read(reader); |
| | | } |
| | | log.debug("[PLUS]å¼å§è¯·æ± => URL[{}],åæ°ç±»å[json],åæ°:[{}]", url, jsonParam); |
| | | } else { |
| | | Map<String, String[]> parameterMap = request.getParameterMap(); |
| | | if (MapUtil.isNotEmpty(parameterMap)) { |
| | | String parameters = JsonUtils.toJsonString(parameterMap); |
| | | log.debug("[PLUS]å¼å§è¯·æ± => URL[{}],åæ°ç±»å[param],åæ°:[{}]", url, parameters); |
| | | } else { |
| | | log.debug("[PLUS]å¼å§è¯·æ± => URL[{}],æ åæ°", url); |
| | | } |
| | | } |
| | | |
| | | StopWatch stopWatch = new StopWatch(); |
| | | invokeTimeTL.set(stopWatch); |
| | | stopWatch.start(); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
| | | if (!"prod".equals(SpringUtils.getActiveProfile())) { |
| | | StopWatch stopWatch = invokeTimeTL.get(); |
| | | stopWatch.stop(); |
| | | log.debug("[PLUS]ç»æè¯·æ± => URL[{}],èæ¶:[{}]毫ç§", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTime()); |
| | | invokeTimeTL.remove(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤ææ¬æ¬¡è¯·æ±çæ°æ®ç±»åæ¯å¦ä¸ºjson |
| | | * |
| | | * @param request request |
| | | * @return boolean |
| | | */ |
| | | private boolean isJsonRequest(HttpServletRequest request) { |
| | | String contentType = request.getContentType(); |
| | | if (contentType != null) { |
| | | return StringUtils.startsWithIgnoreCase(contentType, MediaType.APPLICATION_JSON_VALUE); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | |
| | | @ApiOperation("æ¥è¯¢ä»£ç çæå表") |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<GenTable> genList(GenTable genTable) { |
| | | return genTableService.selectPageGenTableList(genTable); |
| | | public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) { |
| | | return genTableService.selectPageGenTableList(genTable, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ¥è¯¢æ°æ®åºå表") |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping("/db/list") |
| | | public TableDataInfo<GenTable> dataList(GenTable genTable) { |
| | | return genTableService.selectPageDbTableList(genTable); |
| | | public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) { |
| | | return genTableService.selectPageDbTableList(genTable, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.generator.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @InterceptorIgnore(dataPermission = "true") |
| | | public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn> { |
| | | /** |
| | | * æ ¹æ®è¡¨åç§°æ¥è¯¢åä¿¡æ¯ |
| | |
| | | package com.ruoyi.generator.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @InterceptorIgnore(dataPermission = "true") |
| | | public interface GenTableMapper extends BaseMapperPlus<GenTable> { |
| | | |
| | | |
| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable) { |
| | | return PageUtils.buildDataInfo(baseMapper.selectPageGenTableList(PageUtils.buildPage(), genTable)); |
| | | public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) { |
| | | Page<GenTable> page = baseMapper.selectPageGenTableList(pageQuery.build(), genTable); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable) { |
| | | return PageUtils.buildDataInfo(baseMapper.selectPageDbTableList(PageUtils.buildPage(), genTable)); |
| | | public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) { |
| | | Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateGenTable(GenTable genTable) { |
| | | String options = JsonUtils.toJsonString(genTable.getParams()); |
| | | genTable.setOptions(options); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteGenTableByIds(Long[] tableIds) { |
| | | List<Long> ids = Arrays.asList(tableIds); |
| | | removeByIds(ids); |
| | |
| | | * @param tableList 导å
¥è¡¨å表 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importGenTable(List<GenTable> tableList) { |
| | | String operName = LoginUtils.getUsername(); |
| | | try { |
| | |
| | | * @param tableName 表åç§° |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void synchDb(String tableName) { |
| | | GenTable table = baseMapper.selectGenTableByName(tableName); |
| | | List<GenTableColumn> tableColumns = table.getColumns(); |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | |
| | |
| | | public interface IGenTableService extends IService<GenTable> { |
| | | |
| | | |
| | | TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable); |
| | | TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery); |
| | | |
| | | |
| | | TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable); |
| | | TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å表 |
| | |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | import org.apache.velocity.VelocityContext; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 模æ¿å¤çå·¥å
·ç±» |
| | |
| | | */ |
| | | public static String getDicts(GenTable genTable) { |
| | | List<GenTableColumn> columns = genTable.getColumns(); |
| | | List<String> dicts = new ArrayList<String>(); |
| | | Set<String> dicts = new HashSet<String>(); |
| | | for (GenTableColumn column : columns) { |
| | | if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( |
| | | column.getHtmlType(), |
| | |
| | | <result property="remark" column="remark" /> |
| | | <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap type="GenTableColumn" id="GenTableColumnResult"> |
| | | <id property="columnId" column="column_id" /> |
| | | <result property="tableId" column="table_id" /> |
| | |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <sql id="selectGenTableVo"> |
| | | select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table |
| | | </sql> |
| | |
| | | <select id="selectPageDbTableList" parameterType="GenTable" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_schema = (select database()) |
| | | AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT IN (select table_name from gen_table) |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) |
| | |
| | | <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_schema = (select database()) |
| | | AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT IN (select table_name from gen_table) |
| | | <if test="tableName != null and tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{tableName}, '%')) |
| | |
| | | </if> |
| | | order by create_time desc |
| | | </select> |
| | | |
| | | |
| | | <select id="selectDbTableListByNames" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) |
| | | where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) |
| | | and table_name in |
| | | <foreach collection="array" item="name" open="(" separator="," close=")"> |
| | | #{name} |
| | | </foreach> |
| | | </foreach> |
| | | </select> |
| | | |
| | | |
| | | <select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database()) |
| | | and table_name = #{tableName} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | where t.table_id = #{tableId} order by c.sort |
| | | </select> |
| | | |
| | | |
| | | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | where t.table_name = #{tableName} order by c.sort |
| | | </select> |
| | | |
| | | |
| | | <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | |
| | | order by c.sort |
| | | </select> |
| | | |
| | | </mapper> |
| | | </mapper> |
| | |
| | | #end |
| | | #end |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | |
| | | @SaCheckPermission("${permissionPrefix}:list") |
| | | @GetMapping("/list") |
| | | #if($table.crud || $table.sub) |
| | | public TableDataInfo<${ClassName}Vo> list(@Validated(QueryGroup.class) ${ClassName}Bo bo) { |
| | | return i${ClassName}Service.queryPageList(bo); |
| | | public TableDataInfo<${ClassName}Vo> list(@Validated(QueryGroup.class) ${ClassName}Bo bo, PageQuery pageQuery) { |
| | | return i${ClassName}Service.queryPageList(bo, pageQuery); |
| | | } |
| | | #elseif($table.tree) |
| | | public AjaxResult<List<${ClassName}Vo>> list(@Validated(QueryGroup.class) ${ClassName}Bo bo) { |
| | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | #if($table.crud || $table.sub) |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | #end |
| | | |
| | | import java.util.Collection; |
| | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo); |
| | | TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery); |
| | | #end |
| | | |
| | | /** |
| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | #if($table.crud || $table.sub) |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | #end |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | |
| | | |
| | | #if($table.crud || $table.sub) |
| | | @Override |
| | | public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo) { |
| | | PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo); |
| | | Page<${ClassName}Vo> result = pageVo(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | #end |
| | | |
| | | @Override |
| | | public List<${ClassName}Vo> queryList(${ClassName}Bo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | | LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo); |
| | | return listVo(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | | #set($dictType=$column.dictType) |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.htmlType == "input" || $column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-input |
| | | v-model="queryParams.${column.javaField}" |
| | | placeholder="请è¾å
¥${comment}" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="è¯·éæ©${comment}" clearable size="small"> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="è¯·éæ©${comment}" clearable size="small"> |
| | | <el-option label="è¯·éæ©åå
¸çæ" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-date-picker clearable size="small" |
| | | v-model="queryParams.${column.javaField}" |
| | | type="date" |
| | | value-format="YYYY-MM-DD" |
| | | placeholder="éæ©${comment}"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | <el-form-item label="${comment}"> |
| | | <el-date-picker |
| | | v-model="daterange${AttrName}" |
| | | size="small" |
| | | style="width: 240px" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="å¼å§æ¥æ" |
| | | end-placeholder="ç»ææ¥æ" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" size="mini" @click="handleQuery">æç´¢</el-button> |
| | | <el-button icon="Refresh" size="mini" @click="resetQuery">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | size="mini" |
| | | @click="handleAdd" |
| | | v-hasPermi="['${moduleName}:${businessName}:add']" |
| | | >æ°å¢</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table |
| | | v-loading="loading" |
| | | :data="${businessName}List" |
| | | row-key="${treeCode}" |
| | | default-expand-all |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | > |
| | | #foreach($column in $columns) |
| | | #set($javaField=$column.javaField) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.pk) |
| | | #elseif($column.list && $column.htmlType == "datetime") |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && $column.dictType && "" != $column.dictType) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| | | <template #default="scope"> |
| | | #if($column.htmlType == "checkbox") |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> |
| | | #else |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> |
| | | #end |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && "" != $javaField) |
| | | #if(${foreach.index} == 1) |
| | | <el-table-column label="${comment}" prop="${javaField}" /> |
| | | #else |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" /> |
| | | #end |
| | | #end |
| | | #end |
| | | <el-table-column label="æä½" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['${moduleName}:${businessName}:edit']" |
| | | >ä¿®æ¹</el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="Plus" |
| | | @click="handleAdd(scope.row)" |
| | | v-hasPermi="['${moduleName}:${businessName}:add']" |
| | | >æ°å¢</el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['${moduleName}:${businessName}:remove']" |
| | | >å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <!-- æ·»å æä¿®æ¹${functionName}å¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> |
| | | #foreach($column in $columns) |
| | | #set($field=$column.javaField) |
| | | #if($column.insert && !$column.pk) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #set($dictType=$column.dictType) |
| | | #if("" != $treeParentCode && $column.javaField == $treeParentCode) |
| | | <el-form-item label="${comment}" prop="${treeParentCode}"> |
| | | <tree-select |
| | | v-model:value="form.${treeParentCode}" |
| | | :options="${businessName}Options" |
| | | :objMap="{ value: '${treeCode}', label: '${treeName}', children: 'children' }" |
| | | placeholder="è¯·éæ©${comment}" |
| | | /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "input") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" placeholder="请è¾å
¥${comment}" /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "imageUpload") |
| | | <el-form-item label="${comment}"> |
| | | <imageUpload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "fileUpload") |
| | | <el-form-item label="${comment}"> |
| | | <fileUpload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "editor") |
| | | <el-form-item label="${comment}"> |
| | | <editor v-model="form.${field}" :min-height="192"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="è¯·éæ©${comment}"> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end |
| | | |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="è¯·éæ©${comment}"> |
| | | <el-option label="è¯·éæ©åå
¸çæ" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.value"> |
| | | {{dict.label}} |
| | | </el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox>è¯·éæ©åå
¸çæ</el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && "" != $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end |
| | | |
| | | >{{dict.label}}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio label="1">è¯·éæ©åå
¸çæ</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-date-picker clearable size="small" |
| | | v-model="form.${field}" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="éæ©${comment}"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" type="textarea" placeholder="请è¾å
¥å
容" /> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | #end |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">ç¡® å®</el-button> |
| | | <el-button @click="cancel">å æ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="${BusinessName}"> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | #if(${dicts} != '') |
| | | #set($dictsNoSymbol=$dicts.replace("'", "")) |
| | | const { ${dictsNoSymbol} } = proxy.useDict(${dicts}); |
| | | #end |
| | | |
| | | const ${businessName}List = ref([]); |
| | | const ${businessName}Options = ref([]); |
| | | const open = ref(false); |
| | | const buttonLoading = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const title = ref(""); |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | const daterange${AttrName} = ref([]); |
| | | #end |
| | | #end |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | | queryParams: { |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }, |
| | | rules: { |
| | | #foreach ($column in $columns) |
| | | #if($column.required) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$commentä¸è½ä¸ºç©º", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | } |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | /** æ¥è¯¢${functionName}å表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | queryParams.value.params = {}; |
| | | #break |
| | | #end |
| | | #end |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | if (null != daterange${AttrName} && '' != daterange${AttrName}) { |
| | | queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]; |
| | | queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]; |
| | | } |
| | | #end |
| | | #end |
| | | list${BusinessName}(queryParams.value).then(response => { |
| | | ${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}"); |
| | | loading.value = false; |
| | | }); |
| | | } |
| | | |
| | | /** æ¥è¯¢${functionName}䏿æ ç»æ */ |
| | | async function getTreeselect() { |
| | | await list${BusinessName}().then(response => { |
| | | ${businessName}Options.value = []; |
| | | const data = { ${treeCode}: 0, ${treeName}: '顶级èç¹', children: [] }; |
| | | data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}"); |
| | | ${businessName}Options.value.push(data); |
| | | }); |
| | | } |
| | | |
| | | // åæ¶æé® |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | } |
| | | |
| | | // 表åéç½® |
| | | function reset() { |
| | | form.value = { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "radio") |
| | | $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end |
| | | |
| | | #elseif($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }; |
| | | proxy.resetForm("${businessName}Ref"); |
| | | } |
| | | |
| | | /** æç´¢æé®æä½ */ |
| | | function handleQuery() { |
| | | getList(); |
| | | } |
| | | |
| | | /** éç½®æé®æä½ */ |
| | | function resetQuery() { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | daterange${AttrName}.value = []; |
| | | #end |
| | | #end |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | } |
| | | |
| | | /** æ°å¢æé®æä½ */ |
| | | async function handleAdd(row) { |
| | | reset(); |
| | | await getTreeselect(); |
| | | if (row != null && row.${treeCode}) { |
| | | form.value.${treeParentCode} = row.${treeCode}; |
| | | } else { |
| | | form.value.${treeParentCode} = 0; |
| | | } |
| | | open.value = true; |
| | | title.value = "æ·»å ${functionName}"; |
| | | } |
| | | |
| | | /** ä¿®æ¹æé®æä½ */ |
| | | async function handleUpdate(row) { |
| | | loading.value = true; |
| | | reset(); |
| | | await getTreeselect(); |
| | | if (row != null) { |
| | | form.value.${treeParentCode} = row.${treeCode}; |
| | | } |
| | | get${BusinessName}(row.${pkColumn.javaField}).then(response => { |
| | | loading.value = false; |
| | | form.value = response.data; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.split(","); |
| | | #end |
| | | #end |
| | | open.value = true; |
| | | title.value = "ä¿®æ¹${functionName}"; |
| | | }); |
| | | } |
| | | |
| | | /** æäº¤æé® */ |
| | | function submitForm() { |
| | | proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => { |
| | | if (valid) { |
| | | buttonLoading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.join(","); |
| | | #end |
| | | #end |
| | | if (form.value.${pkColumn.javaField} != null) { |
| | | update${BusinessName}(form.value).then(response => { |
| | | proxy.#[[$modal]]#.msgSuccess("ä¿®æ¹æå"); |
| | | open.value = false; |
| | | getList(); |
| | | }).finally(() => { |
| | | buttonLoading.value = false; |
| | | }); |
| | | } else { |
| | | add${BusinessName}(form.value).then(response => { |
| | | proxy.#[[$modal]]#.msgSuccess("æ°å¢æå"); |
| | | open.value = false; |
| | | getList(); |
| | | }).finally(() => { |
| | | buttonLoading.value = false; |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** å é¤æé®æä½ */ |
| | | function handleDelete(row) { |
| | | proxy.#[[$modal]]#.confirm('æ¯å¦ç¡®è®¤å é¤${functionName}ç¼å·ä¸º"' + row.${pkColumn.javaField} + '"çæ°æ®é¡¹ï¼').then(function() { |
| | | loading.value = true; |
| | | return del${BusinessName}(row.${pkColumn.javaField}); |
| | | }).then(() => { |
| | | loading.value = false; |
| | | getList(); |
| | | proxy.#[[$modal]]#.msgSuccess("å 餿å"); |
| | | }).finally(() => { |
| | | loading.value = false; |
| | | }); |
| | | } |
| | | |
| | | getList(); |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | | #set($dictType=$column.dictType) |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.htmlType == "input" || $column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-input |
| | | v-model="queryParams.${column.javaField}" |
| | | placeholder="请è¾å
¥${comment}" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="è¯·éæ©${comment}" clearable size="small"> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="è¯·éæ©${comment}" clearable size="small"> |
| | | <el-option label="è¯·éæ©åå
¸çæ" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-date-picker clearable size="small" |
| | | v-model="queryParams.${column.javaField}" |
| | | type="date" |
| | | value-format="YYYY-MM-DD" |
| | | placeholder="éæ©${comment}"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | <el-form-item label="${comment}"> |
| | | <el-date-picker |
| | | v-model="daterange${AttrName}" |
| | | size="small" |
| | | style="width: 240px" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="å¼å§æ¥æ" |
| | | end-placeholder="ç»ææ¥æ" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" size="mini" @click="handleQuery">æç´¢</el-button> |
| | | <el-button icon="Refresh" size="mini" @click="resetQuery">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | size="mini" |
| | | @click="handleAdd" |
| | | v-hasPermi="['${moduleName}:${businessName}:add']" |
| | | >æ°å¢</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | size="mini" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['${moduleName}:${businessName}:edit']" |
| | | >ä¿®æ¹</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | size="mini" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['${moduleName}:${businessName}:remove']" |
| | | >å é¤</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | size="mini" |
| | | @click="handleExport" |
| | | v-hasPermi="['${moduleName}:${businessName}:export']" |
| | | >导åº</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | #foreach($column in $columns) |
| | | #set($javaField=$column.javaField) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.pk) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" v-if="${column.list}"/> |
| | | #elseif($column.list && $column.htmlType == "datetime") |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && $column.dictType && "" != $column.dictType) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| | | <template #default="scope"> |
| | | #if($column.htmlType == "checkbox") |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> |
| | | #else |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> |
| | | #end |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && "" != $javaField) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" /> |
| | | #end |
| | | #end |
| | | <el-table-column label="æä½" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['${moduleName}:${businessName}:edit']" |
| | | >ä¿®æ¹</el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['${moduleName}:${businessName}:remove']" |
| | | >å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total>0" |
| | | :total="total" |
| | | v-model:p:page="queryParams.pageNum" |
| | | v-model:p:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- æ·»å æä¿®æ¹${functionName}å¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> |
| | | #foreach($column in $columns) |
| | | #set($field=$column.javaField) |
| | | #if($column.insert && !$column.pk) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #set($dictType=$column.dictType) |
| | | #if($column.htmlType == "input") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" placeholder="请è¾å
¥${comment}" /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "imageUpload") |
| | | <el-form-item label="${comment}"> |
| | | <imageUpload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "fileUpload") |
| | | <el-form-item label="${comment}"> |
| | | <fileUpload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "editor") |
| | | <el-form-item label="${comment}"> |
| | | <editor v-model="form.${field}" :min-height="192"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="è¯·éæ©${comment}"> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end |
| | | |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="è¯·éæ©${comment}"> |
| | | <el-option label="è¯·éæ©åå
¸çæ" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.value"> |
| | | {{dict.label}} |
| | | </el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox>è¯·éæ©åå
¸çæ</el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && "" != $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end |
| | | |
| | | >{{dict.label}}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && $dictType) |
| | | <el-form-item label="${comment}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio label="1">è¯·éæ©åå
¸çæ</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-date-picker clearable size="small" |
| | | v-model="form.${field}" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="éæ©${comment}"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" type="textarea" placeholder="请è¾å
¥å
容" /> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | #if($table.sub) |
| | | <el-divider content-position="center">${subTable.functionName}ä¿¡æ¯</el-divider> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" icon="Plus" size="mini" @click="handleAdd${subClassName}">æ·»å </el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" icon="Delete" size="mini" @click="handleDelete${subClassName}">å é¤</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}"> |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column label="åºå·" align="center" prop="index" width="50"/> |
| | | #foreach($column in $subTable.columns) |
| | | #set($javaField=$column.javaField) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.pk || $javaField == ${subTableFkclassName}) |
| | | #elseif($column.list && "" != $javaField) |
| | | <el-table-column label="$comment" prop="${javaField}"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.$javaField" placeholder="请è¾å
¥$comment" /> |
| | | </template> |
| | | </el-table-column> |
| | | #end |
| | | #end |
| | | </el-table> |
| | | #end |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button :loading="buttonLoading" type="primary" @click="submitForm">ç¡® å®</el-button> |
| | | <el-button @click="cancel">å æ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="${BusinessName}"> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | #if(${dicts} != '') |
| | | #set($dictsNoSymbol=$dicts.replace("'", "")) |
| | | const { ${dictsNoSymbol} } = proxy.useDict(${dicts}); |
| | | #end |
| | | |
| | | const ${businessName}List = ref([]); |
| | | #if($table.sub) |
| | | const ${subclassName}List = ref([]); |
| | | #end |
| | | const open = ref(false); |
| | | const buttonLoading = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | #if($table.sub) |
| | | const checked${subClassName} = ref([]); |
| | | #end |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | const daterange${AttrName} = ref([]); |
| | | #end |
| | | #end |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }, |
| | | rules: { |
| | | #foreach ($column in $columns) |
| | | #if($column.required) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$commentä¸è½ä¸ºç©º", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | } |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | /** æ¥è¯¢${functionName}å表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | queryParams.value.params = {}; |
| | | #break |
| | | #end |
| | | #end |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | if (null != daterange${AttrName} && '' != daterange${AttrName}) { |
| | | queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]; |
| | | queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]; |
| | | } |
| | | #end |
| | | #end |
| | | list${BusinessName}(queryParams.value).then(response => { |
| | | ${businessName}List.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | } |
| | | |
| | | // åæ¶æé® |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | } |
| | | |
| | | // 表åéç½® |
| | | function reset() { |
| | | form.value = { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "radio") |
| | | $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end |
| | | #elseif($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }; |
| | | #if($table.sub) |
| | | ${subclassName}List.value = []; |
| | | #end |
| | | proxy.resetForm("${businessName}Ref"); |
| | | } |
| | | |
| | | /** æç´¢æé®æä½ */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | } |
| | | |
| | | /** éç½®æé®æä½ */ |
| | | function resetQuery() { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | daterange${AttrName}.value = []; |
| | | #end |
| | | #end |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | } |
| | | |
| | | // å¤éæ¡é䏿°æ® |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.${pkColumn.javaField}); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | } |
| | | |
| | | /** æ°å¢æé®æä½ */ |
| | | function handleAdd() { |
| | | reset(); |
| | | open.value = true; |
| | | title.value = "æ·»å ${functionName}"; |
| | | } |
| | | |
| | | /** ä¿®æ¹æé®æä½ */ |
| | | function handleUpdate(row) { |
| | | loading.value = true |
| | | reset(); |
| | | const ${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value |
| | | get${BusinessName}(${pkColumn.javaField}).then(response => { |
| | | loading.value = false; |
| | | form.value = response.data; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.split(","); |
| | | #end |
| | | #end |
| | | #if($table.sub) |
| | | ${subclassName}List.value = response.data.${subclassName}List; |
| | | #end |
| | | open.value = true; |
| | | title.value = "ä¿®æ¹${functionName}"; |
| | | }); |
| | | } |
| | | |
| | | /** æäº¤æé® */ |
| | | function submitForm() { |
| | | proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => { |
| | | if (valid) { |
| | | buttonLoading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.join(","); |
| | | #end |
| | | #end |
| | | #if($table.sub) |
| | | form.value.${subclassName}List = ${subclassName}List.value; |
| | | #end |
| | | if (form.value.${pkColumn.javaField} != null) { |
| | | update${BusinessName}(form.value).then(response => { |
| | | proxy.#[[$modal]]#.msgSuccess("ä¿®æ¹æå"); |
| | | open.value = false; |
| | | getList(); |
| | | }).finally(() => { |
| | | buttonLoading.value = false; |
| | | }); |
| | | } else { |
| | | add${BusinessName}(form.value).then(response => { |
| | | proxy.#[[$modal]]#.msgSuccess("æ°å¢æå"); |
| | | open.value = false; |
| | | getList(); |
| | | }).finally(() => { |
| | | buttonLoading.value = false; |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** å é¤æé®æä½ */ |
| | | function handleDelete(row) { |
| | | const ${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value; |
| | | proxy.#[[$modal]]#.confirm('æ¯å¦ç¡®è®¤å é¤${functionName}ç¼å·ä¸º"' + ${pkColumn.javaField}s + '"çæ°æ®é¡¹ï¼').then(function() { |
| | | loading.value = true; |
| | | return del${BusinessName}(${pkColumn.javaField}s); |
| | | }).then(() => { |
| | | loading.value = true; |
| | | getList(); |
| | | proxy.#[[$modal]]#.msgSuccess("å 餿å"); |
| | | }).finally(() => { |
| | | loading.value = false; |
| | | }); |
| | | } |
| | | |
| | | #if($table.sub) |
| | | /** ${subTable.functionName}åºå· */ |
| | | function row${subClassName}Index({ row, rowIndex }) { |
| | | row.index = rowIndex + 1; |
| | | } |
| | | |
| | | /** ${subTable.functionName}æ·»å æé®æä½ */ |
| | | function handleAdd${subClassName}() { |
| | | let obj = {}; |
| | | #foreach($column in $subTable.columns) |
| | | #if($column.pk || $column.javaField == ${subTableFkclassName}) |
| | | #elseif($column.list && "" != $javaField) |
| | | obj.$column.javaField = ""; |
| | | #end |
| | | #end |
| | | ${subclassName}List.value.push(obj); |
| | | } |
| | | |
| | | /** ${subTable.functionName}å é¤æé®æä½ */ |
| | | function handleDelete${subClassName}() { |
| | | if (checked${subClassName}.value.length == 0) { |
| | | proxy.#[[$modal]]#.msgError("请å
éæ©è¦å é¤ç${subTable.functionName}æ°æ®"); |
| | | } else { |
| | | const ${subclassName}s = ${subclassName}List.value; |
| | | const checked${subClassName}s = checked${subClassName}.value; |
| | | ${subclassName}List.value = ${subclassName}s.filter(function(item) { |
| | | return checked${subClassName}s.indexOf(item.index) == -1 |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** å¤éæ¡é䏿°æ® */ |
| | | function handle${subClassName}SelectionChange(selection) { |
| | | checked${subClassName}.value = selection.map(item => item.index) |
| | | } |
| | | |
| | | #end |
| | | /** å¯¼åºæé®æä½ */ |
| | | function handleExport() { |
| | | proxy.download('${moduleName}/${businessName}/export', { |
| | | ...queryParams.value |
| | | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) |
| | | } |
| | | |
| | | getList(); |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | å¦æä½¿ç¨çæ¯RuoYi-Vue3å端ï¼é£ä¹éè¦è¦çä¸ä¸æ¤ç®å½ç模æ¿index.vue.vmãindex-tree.vue.vmæä»¶å°ä¸çº§vueç®å½ã |
| | |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-xxl-job</artifactId> |
| | | <artifactId>tlog-xxljob-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | |
| | | |
| | | import com.ruoyi.job.config.properties.XxlJobProperties; |
| | | import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; |
| | | import com.yomahub.tlog.springboot.lifecircle.TLogXxljobEnhanceInit; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | |
| | | return xxlJobSpringExecutor; |
| | | } |
| | | |
| | | @Bean |
| | | public TLogXxljobEnhanceInit tLogXxljobEnhanceInit(){ |
| | | return new TLogXxljobEnhanceInit(); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.xss.Xss; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.Size; |
| | | |
| | | |
| | | /** |
| | | * éç¥å
¬å表 sys_notice |
| | |
| | | /** |
| | | * å
¬åæ é¢ |
| | | */ |
| | | @Xss(message = "å
¬åæ é¢ä¸è½å
å«èæ¬å符") |
| | | @ApiModelProperty(value = "å
¬åæ é¢") |
| | | @NotBlank(message = "å
¬åæ é¢ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 50, message = "å
¬åæ é¢ä¸è½è¶
è¿50个å符") |
| | |
| | | * 主建 |
| | | */ |
| | | @TableId(value = "oss_config_id") |
| | | private Integer ossConfigId; |
| | | private Long ossConfigId; |
| | | |
| | | /** |
| | | * é
ç½®key |
| | |
| | | public class SysOssBo extends BaseEntity { |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | |
| | | /** |
| | | * æä»¶å |
| | | */ |
| | | @ApiModelProperty("æä»¶å") |
| | |
| | | @ApiModelProperty(value = "æ©å±å段") |
| | | private String ext1; |
| | | |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.utils.LoginUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.vo.SysUserImportVo; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | |
| | | private final StringBuilder failureMsg = new StringBuilder(); |
| | | |
| | | public SysUserImportListener(Boolean isUpdateSupport) { |
| | | String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword"); |
| | | this.userService = SpringUtils.getBean(ISysUserService.class); |
| | | this.password = SpringUtils.getBean(ISysConfigService.class) |
| | | .selectConfigByKey("sys.user.initPassword"); |
| | | this.password = SecurityUtils.encryptPassword(initPassword); |
| | | this.isUpdateSupport = isUpdateSupport; |
| | | this.operName = LoginUtils.getUsername(); |
| | | } |
| | |
| | | // éªè¯æ¯å¦åå¨è¿ä¸ªç¨æ· |
| | | if (StringUtils.isNull(user)) { |
| | | user = BeanUtil.toBean(userVo, SysUser.class); |
| | | user.setPassword(SecurityUtils.encryptPassword(password)); |
| | | ValidatorUtils.validate(user); |
| | | user.setPassword(password); |
| | | user.setCreateBy(operName); |
| | | userService.insertUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("ãè´¦å· ").append(user.getUserName()).append(" 导å
¥æå"); |
| | | } else if (isUpdateSupport) { |
| | | ValidatorUtils.validate(user); |
| | | user.setUpdateBy(operName); |
| | | userService.updateUser(user); |
| | | successNum++; |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return é¨é¨ä¿¡æ¯éå |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id") |
| | | }) |
| | | List<SysDept> selectDeptList(SysDept dept); |
| | | |
| | | /** |
| | |
| | | * @param deptCheckStrictly é¨é¨æ 鿩项æ¯å¦å
³èæ¾ç¤º |
| | | * @return éä¸é¨é¨å表 |
| | | */ |
| | | List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); |
| | | List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); |
| | | |
| | | /** |
| | | * ä¿®æ¹åå
ç´ å
³ç³» |
| | |
| | | * @param userId ç¨æ·ID |
| | | * @return éä¸å²ä½IDå表 |
| | | */ |
| | | List<Integer> selectPostListByUserId(Long userId); |
| | | List<Long> selectPostListByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¨æ·æå±å²ä½ç» |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | */ |
| | | public interface SysRoleMapper extends BaseMapperPlus<SysRole> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id") |
| | | }) |
| | | Page<SysRole> selectPageRoleList(@Param("page") Page<SysRole> page, @Param("role") SysRole role); |
| | | |
| | | /** |
| | |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return è§è²æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id") |
| | | }) |
| | | List<SysRole> selectRoleList(SysRole role); |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | */ |
| | | public interface SysUserMapper extends BaseMapperPlus<SysUser> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | Page<SysUser> selectPageUserList(@Param("page") Page<SysUser> page, @Param("user") SysUser user); |
| | | |
| | | /** |
| | |
| | | * @param sysUser ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | List<SysUser> selectUserList(SysUser sysUser); |
| | | |
| | | /** |
| | |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | Page<SysUser> selectAllocatedList(@Param("page") Page<SysUser> page, @Param("user") SysUser user); |
| | | |
| | | /** |
| | |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | Page<SysUser> selectUnallocatedList(@Param("page") Page<SysUser> page, @Param("user") SysUser user); |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | |
| | |
| | | public interface ISysConfigService extends IService<SysConfig> { |
| | | |
| | | |
| | | TableDataInfo<SysConfig> selectPageConfigList(SysConfig config); |
| | | TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | |
| | | * @param roleId è§è²ID |
| | | * @return éä¸é¨é¨å表 |
| | | */ |
| | | List<Integer> selectDeptListByRoleId(Long roleId); |
| | | List<Long> selectDeptListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨IDæ¥è¯¢ä¿¡æ¯ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | |
| | | public interface ISysDictDataService extends IService<SysDictData> { |
| | | |
| | | |
| | | TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData); |
| | | TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢åå
¸æ°æ® |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | public interface ISysDictTypeService extends IService<SysDictType> { |
| | | |
| | | |
| | | TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType); |
| | | TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢åå
¸ç±»å |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | |
| | |
| | | public interface ISysLogininforService extends IService<SysLogininfor> { |
| | | |
| | | |
| | | TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor); |
| | | TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ°å¢ç³»ç»ç»å½æ¥å¿ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | |
| | |
| | | public interface ISysNoticeService extends IService<SysNotice> { |
| | | |
| | | |
| | | TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice); |
| | | TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ¥è¯¢å
¬åä¿¡æ¯ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | |
| | |
| | | */ |
| | | public interface ISysOperLogService extends IService<SysOperLog> { |
| | | |
| | | TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog); |
| | | TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ°å¢æä½æ¥å¿ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo); |
| | | TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery); |
| | | |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOss; |
| | |
| | | */ |
| | | public interface ISysOssService extends IServicePlus<SysOss, SysOssVo> { |
| | | |
| | | TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss); |
| | | TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery); |
| | | |
| | | SysOss upload(MultipartFile file); |
| | | |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | |
| | |
| | | public interface ISysPostService extends IService<SysPost> { |
| | | |
| | | |
| | | TableDataInfo<SysPost> selectPagePostList(SysPost post); |
| | | TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ¥è¯¢å²ä½ä¿¡æ¯éå |
| | |
| | | * @param userId ç¨æ·ID |
| | | * @return éä¸å²ä½IDå表 |
| | | */ |
| | | List<Integer> selectPostListByUserId(Long userId); |
| | | List<Long> selectPostListByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ ¡éªå²ä½åç§° |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | |
| | | public interface ISysRoleService extends IService<SysRole> { |
| | | |
| | | |
| | | TableDataInfo<SysRole> selectPageRoleList(SysRole role); |
| | | TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢è§è²æ°æ® |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.UserService; |
| | |
| | | public interface ISysUserService extends IService<SysUser>, UserService { |
| | | |
| | | |
| | | TableDataInfo<SysUser> selectPageUserList(SysUser user); |
| | | TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢ç¨æ·å表 |
| | |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | TableDataInfo<SysUser> selectAllocatedList(SysUser user); |
| | | TableDataInfo<SysUser> selectAllocatedList(SysUser user, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢æªåé
ç¨æ·è§è²å表 |
| | |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | TableDataInfo<SysUser> selectUnallocatedList(SysUser user); |
| | | TableDataInfo<SysUser> selectUnallocatedList(SysUser user, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·åæ¥è¯¢ç¨æ· |
| | |
| | | */ |
| | | int deleteUserByIds(Long[] userIds); |
| | | |
| | | /** |
| | | * 导å
¥ç¨æ·æ°æ® |
| | | * |
| | | * @param userList ç¨æ·æ°æ®å表 |
| | | * @param isUpdateSupport æ¯å¦æ´æ°æ¯æï¼å¦æå·²åå¨ï¼åè¿è¡æ´æ°æ°æ® |
| | | * @param operName æä½ç¨æ· |
| | | * @return ç»æ |
| | | */ |
| | | String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | /** |
| | | * éç¨ æ°æ®æé æå¡ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDataScopeService { |
| | | |
| | | /** |
| | | * è·åè§è²èªå®ä¹æé |
| | | * @param roleId è§è²id |
| | | * @return é¨é¨idç» |
| | | */ |
| | | String getRoleCustom(Long roleId); |
| | | |
| | | /** |
| | | * è·åé¨é¨å以䏿é |
| | | * @param deptId é¨é¨id |
| | | * @return é¨é¨idç» |
| | | */ |
| | | String getDeptAndChild(Long deptId); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.user.CaptchaException; |
| | | import com.ruoyi.common.exception.user.CaptchaExpireException; |
| | | import com.ruoyi.common.exception.user.UserPasswordNotMatchException; |
| | | import com.ruoyi.common.exception.user.UserException; |
| | | import com.ruoyi.common.utils.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * ç»å½æ ¡éªæ¹æ³ |
| | |
| | | if (captchaOnOff) { |
| | | validateCaptcha(username, code, uuid, request); |
| | | } |
| | | // è·åç¨æ·ç»å½é误次æ°(å¯èªå®ä¹éå¶çç¥ ä¾å¦: key + username + ip) |
| | | Integer errorNumber = RedisUtils.getCacheObject(Constants.LOGIN_ERROR + username); |
| | | // é宿¶é´å
ç»å½ åè¸¢åº |
| | | if (ObjectUtil.isNotNull(errorNumber) && errorNumber.equals(Constants.LOGIN_ERROR_NUMBER)) { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME), request); |
| | | throw new UserException("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME); |
| | | } |
| | | |
| | | SysUser user = userService.selectUserByUserName(username); |
| | | if (StringUtils.isNull(user)) { |
| | | log.info("ç»å½ç¨æ·ï¼{} ä¸åå¨.", username); |
| | | throw new ServiceException("ç»å½ç¨æ·ï¼" + username + " ä¸åå¨"); |
| | | throw new UserException("user.not.exists", username); |
| | | } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { |
| | | log.info("ç»å½ç¨æ·ï¼{} 已被å é¤.", username); |
| | | throw new ServiceException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " 已被å é¤"); |
| | | throw new UserException("user.password.delete", username); |
| | | } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { |
| | | log.info("ç»å½ç¨æ·ï¼{} 已被åç¨.", username); |
| | | throw new ServiceException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " å·²åç¨"); |
| | | throw new UserException("user.blocked", username); |
| | | } |
| | | if (!SecurityUtils.matchesPassword(password, user.getPassword())) { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"), request); |
| | | throw new UserPasswordNotMatchException(); |
| | | // æ¯å¦ç¬¬ä¸æ¬¡ |
| | | errorNumber = ObjectUtil.isNull(errorNumber) ? 1 : errorNumber + 1; |
| | | // è¾¾å°è§å®éè¯¯æ¬¡æ° åéå®ç»å½ |
| | | if (errorNumber.equals(Constants.LOGIN_ERROR_NUMBER)) { |
| | | RedisUtils.setCacheObject(Constants.LOGIN_ERROR + username, errorNumber, Constants.LOGIN_ERROR_LIMIT_TIME, TimeUnit.MINUTES); |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME), request); |
| | | throw new UserException("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME); |
| | | } else { |
| | | // æªè¾¾å°è§å®éè¯¯æ¬¡æ° åéå¢ |
| | | RedisUtils.setCacheObject(Constants.LOGIN_ERROR + username, errorNumber); |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", errorNumber), request); |
| | | throw new UserException("user.password.retry.limit.count", errorNumber); |
| | | } |
| | | } |
| | | |
| | | // ç»å½æå æ¸
空éè¯¯æ¬¡æ° |
| | | RedisUtils.deleteObject(Constants.LOGIN_ERROR + username); |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request); |
| | | recordLoginInfo(user.getUserId(), username); |
| | | |
| | | LoginUser loginUser = new LoginUser(); |
| | | loginUser.setUserId(user.getUserId()); |
| | | loginUser.setDeptId(user.getDeptId()); |
| | |
| | | loginUser.setMenuPermission(permissionService.getMenuPermission(user)); |
| | | loginUser.setRolePermission(permissionService.getRolePermission(user)); |
| | | |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request); |
| | | recordLoginInfo(user.getUserId(), username); |
| | | // çætoken |
| | | LoginUtils.loginByDevice(loginUser, UserType.SYS_USER, DeviceType.PC); |
| | | return StpUtil.getTokenValue(); |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.DataSource; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.ConfigService; |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | |
| | | public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig, SysConfig> implements ISysConfigService, ConfigService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config) { |
| | | public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery) { |
| | | Map<String, Object> params = config.getParams(); |
| | | LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | Page<SysConfig> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return åæ°é
ç½®ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @DataSource(DataSourceType.MASTER) |
| | | @DS("master") |
| | | public SysConfig selectConfigById(Long configId) { |
| | | return baseMapper.selectById(configId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleDeptMapper; |
| | | import com.ruoyi.system.service.SysDataScopeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service("sdss") |
| | | public class SysDataScopeServiceImpl implements SysDataScopeService { |
| | | |
| | | @Autowired |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | @Autowired |
| | | private SysDeptMapper deptMapper; |
| | | |
| | | @Override |
| | | public String getRoleCustom(Long roleId) { |
| | | List<SysRoleDept> list = roleDeptMapper.selectList( |
| | | new LambdaQueryWrapper<SysRoleDept>() |
| | | .select(SysRoleDept::getDeptId) |
| | | .eq(SysRoleDept::getRoleId, roleId)); |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | return list.stream().map(rd -> Convert.toStr(rd.getDeptId())).collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getDeptAndChild(Long deptId) { |
| | | List<SysDept> list = deptMapper.selectList(new LambdaQueryWrapper<SysDept>() |
| | | .select(SysDept::getDeptId) |
| | | .eq(SysDept::getDeptId, deptId) |
| | | .or() |
| | | .apply("find_in_set({0},ancestors)", deptId)); |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | return list.stream().map(d -> Convert.toStr(d.getDeptId())).collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | |
| | | * @return é¨é¨ä¿¡æ¯éå |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d") |
| | | public List<SysDept> selectDeptList(SysDept dept) { |
| | | // return baseMapper.selectList(); |
| | | // return baseMapper.selectList(new LambdaQueryWrapper<>()); |
| | | return baseMapper.selectDeptList(dept); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts) { |
| | | return TreeBuildUtils.build(depts, (dept, tree) -> |
| | | if (CollUtil.isEmpty(depts)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | Long parentId = depts.get(0).getParentId(); |
| | | return TreeBuildUtils.build(depts, parentId, (dept, tree) -> |
| | | tree.setId(dept.getDeptId()) |
| | | .setParentId(dept.getParentId()) |
| | | .setName(dept.getDeptName()) |
| | |
| | | * @return éä¸é¨é¨å表 |
| | | */ |
| | | @Override |
| | | public List<Integer> selectDeptListByRoleId(Long roleId) { |
| | | public List<Long> selectDeptListByRoleId(Long roleId) { |
| | | SysRole role = roleMapper.selectById(roleId); |
| | | return baseMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | |
| | | public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, SysDictData, SysDictData> implements ISysDictDataService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData) { |
| | | public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysDictData> lqw = new LambdaQueryWrapper<SysDictData>() |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | Page<SysDictData> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.DictService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | |
| | | private SysDictDataMapper dictDataMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType) { |
| | | public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | LambdaQueryWrapper<SysDictType> lqw = new LambdaQueryWrapper<SysDictType>() |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | Page<SysDictType> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateDictType(SysDictType dict) { |
| | | SysDictType oldDict = getById(dict.getDictId()); |
| | | dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() |
| | |
| | | import cn.hutool.http.useragent.UserAgent; |
| | | import cn.hutool.http.useragent.UserAgentUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.LogininforService; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor) { |
| | | public TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor, PageQuery pageQuery) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | LambdaQueryWrapper<SysLogininfor> lqw = new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("info_id", "desc"), lqw)); |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("info_id").setIsAsc("desc"); |
| | | } |
| | | Page<SysLogininfor> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | router.setPath("/inner"); |
| | | List<RouterVo> childrenList = new ArrayList<RouterVo>(); |
| | | RouterVo children = new RouterVo(); |
| | | String routerPath = StringUtils.replaceEach(menu.getPath(), new String[]{Constants.HTTP, Constants.HTTPS}, new String[]{"", ""}); |
| | | String routerPath = innerLinkReplaceEach(menu.getPath()); |
| | | children.setPath(routerPath); |
| | | children.setComponent(UserConstants.INNER_LINK); |
| | | children.setName(StringUtils.capitalize(routerPath)); |
| | |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus) { |
| | | return TreeBuildUtils.build(menus, (menu, tree) -> |
| | | if (CollUtil.isEmpty(menus)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | Long parentId = menus.get(0).getParentId(); |
| | | return TreeBuildUtils.build(menus, parentId, (menu, tree) -> |
| | | tree.setId(menu.getMenuId()) |
| | | .setParentId(menu.getParentId()) |
| | | .setName(menu.getMenuName()) |
| | |
| | | String routerPath = menu.getPath(); |
| | | // å
龿å¼å¤ç½æ¹å¼ |
| | | if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) { |
| | | routerPath = StringUtils.replaceEach(routerPath, new String[]{Constants.HTTP, Constants.HTTPS}, new String[]{"", ""}); |
| | | routerPath = innerLinkReplaceEach(routerPath); |
| | | } |
| | | // éå¤é¾å¹¶ä¸æ¯ä¸çº§ç®å½ï¼ç±»å为ç®å½ï¼ |
| | | if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) |
| | |
| | | private boolean hasChild(List<SysMenu> list, SysMenu t) { |
| | | return getChildList(list, t).size() > 0; |
| | | } |
| | | |
| | | /** |
| | | * å
é¾ååç¹æ®åç¬¦æ¿æ¢ |
| | | * |
| | | * @return |
| | | */ |
| | | public String innerLinkReplaceEach(String path) |
| | | { |
| | | return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS }, |
| | | new String[] { "", "" }); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | import com.ruoyi.system.mapper.SysNoticeMapper; |
| | |
| | | public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNotice, SysNotice> implements ISysNoticeService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice) { |
| | | public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysNotice> lqw = new LambdaQueryWrapper<SysNotice>() |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | Page<SysNotice> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.dto.OperLogDTO; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.OperLogService; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog) { |
| | | public TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog, PageQuery pageQuery) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | LambdaQueryWrapper<SysOperLog> lqw = new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("oper_id", "desc"), lqw)); |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("oper_id").setIsAsc("desc"); |
| | | } |
| | | Page<SysOperLog> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo) { |
| | | PagePlus<SysOssConfig, SysOssConfigVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysOssConfig> lqw = buildQueryWrapper(bo); |
| | | Page<SysOssConfigVo> result = pageVo(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | |
| | | public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, SysOssVo> implements ISysOssService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo) { |
| | | PagePlus<SysOss, SysOssVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo); |
| | | Page<SysOssVo> result = pageVo(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) { |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | |
| | | private SysUserPostMapper userPostMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysPost> selectPagePostList(SysPost post) { |
| | | public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysPost> lqw = new LambdaQueryWrapper<SysPost>() |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | Page<SysPost> page = page(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return éä¸å²ä½IDå表 |
| | | */ |
| | | @Override |
| | | public List<Integer> selectPostListByUserId(Long userId) { |
| | | public List<Long> selectPostListByUserId(Long userId) { |
| | | return baseMapper.selectPostListByUserId(userId); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.LoginUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | |
| | | @Override |
| | | @DataScope(deptAlias = "d") |
| | | public TableDataInfo<SysRole> selectPageRoleList(SysRole role) { |
| | | return PageUtils.buildDataInfo(baseMapper.selectPageRoleList(PageUtils.buildPage(), role)); |
| | | public TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery) { |
| | | Page<SysRole> page = baseMapper.selectPageRoleList(pageQuery.build(), role); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return è§è²æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d") |
| | | public List<SysRole> selectRoleList(SysRole role) { |
| | | return baseMapper.selectRoleList(role); |
| | | } |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int insertRole(SysRole role) { |
| | | // æ°å¢è§è²ä¿¡æ¯ |
| | | baseMapper.insert(role); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateRole(SysRole role) { |
| | | // ä¿®æ¹è§è²ä¿¡æ¯ |
| | | baseMapper.updateById(role); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int authDataScope(SysRole role) { |
| | | // ä¿®æ¹è§è²ä¿¡æ¯ |
| | | baseMapper.updateById(role); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteRoleById(Long roleId) { |
| | | // å é¤è§è²ä¸èåå
³è |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId)); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteRoleByIds(Long[] roleIds) { |
| | | for (Long roleId : roleIds) { |
| | | checkRoleAllowed(new SysRole(roleId)); |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | |
| | | import com.ruoyi.common.core.service.UserService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.LoginUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * ç¨æ· ä¸å¡å±å¤ç |
| | |
| | | @Autowired |
| | | private SysUserPostMapper userPostMapper; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u", isUser = true) |
| | | public TableDataInfo<SysUser> selectPageUserList(SysUser user) { |
| | | return PageUtils.buildDataInfo(baseMapper.selectPageUserList(PageUtils.buildPage(), user)); |
| | | public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) { |
| | | Page<SysUser> page = baseMapper.selectPageUserList(pageQuery.build(), user); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u", isUser = true) |
| | | public List<SysUser> selectUserList(SysUser user) { |
| | | return baseMapper.selectUserList(user); |
| | | } |
| | |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u", isUser = true) |
| | | public TableDataInfo<SysUser> selectAllocatedList(SysUser user) { |
| | | return PageUtils.buildDataInfo(baseMapper.selectAllocatedList(PageUtils.buildPage(), user)); |
| | | public TableDataInfo<SysUser> selectAllocatedList(SysUser user, PageQuery pageQuery) { |
| | | Page<SysUser> page = baseMapper.selectAllocatedList(pageQuery.build(), user); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u", isUser = true) |
| | | public TableDataInfo<SysUser> selectUnallocatedList(SysUser user) { |
| | | return PageUtils.buildDataInfo(baseMapper.selectUnallocatedList(PageUtils.buildPage(), user)); |
| | | public TableDataInfo<SysUser> selectUnallocatedList(SysUser user, PageQuery pageQuery) { |
| | | Page<SysUser> page = baseMapper.selectUnallocatedList(pageQuery.build(), user); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String selectUserRoleGroup(String userName) { |
| | | List<SysRole> list = roleMapper.selectRolesByUserName(userName); |
| | | StringBuilder idsStr = new StringBuilder(); |
| | | for (SysRole role : list) { |
| | | idsStr.append(role.getRoleName()).append(","); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return StringUtils.EMPTY; |
| | | } |
| | | if (StringUtils.isNotEmpty(idsStr.toString())) { |
| | | return idsStr.substring(0, idsStr.length() - 1); |
| | | } |
| | | return idsStr.toString(); |
| | | return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(",")); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String selectUserPostGroup(String userName) { |
| | | List<SysPost> list = postMapper.selectPostsByUserName(userName); |
| | | StringBuilder idsStr = new StringBuilder(); |
| | | for (SysPost post : list) { |
| | | idsStr.append(post.getPostName()).append(","); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return StringUtils.EMPTY; |
| | | } |
| | | if (StringUtils.isNotEmpty(idsStr.toString())) { |
| | | return idsStr.substring(0, idsStr.length() - 1); |
| | | } |
| | | return idsStr.toString(); |
| | | return list.stream().map(SysPost::getPostName).collect(Collectors.joining(",")); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int insertUser(SysUser user) { |
| | | // æ°å¢ç¨æ·ä¿¡æ¯ |
| | | int rows = baseMapper.insert(user); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateUser(SysUser user) { |
| | | Long userId = user.getUserId(); |
| | | // å é¤ç¨æ·ä¸è§è²å
³è |
| | |
| | | * @param roleIds è§è²ç» |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void insertUserAuth(Long userId, Long[] roleIds) { |
| | | userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getUserId, userId)); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteUserById(Long userId) { |
| | | // å é¤ç¨æ·ä¸è§è²å
³è |
| | | userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId)); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteUserByIds(Long[] userIds) { |
| | | for (Long userId : userIds) { |
| | | checkUserAllowed(new SysUser(userId)); |
| | |
| | | return baseMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥ç¨æ·æ°æ® |
| | | * |
| | | * @param userList ç¨æ·æ°æ®å表 |
| | | * @param isUpdateSupport æ¯å¦æ´æ°æ¯æï¼å¦æå·²åå¨ï¼åè¿è¡æ´æ°æ°æ® |
| | | * @param operName æä½ç¨æ· |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) { |
| | | if (StringUtils.isNull(userList) || userList.size() == 0) { |
| | | throw new ServiceException("导å
¥ç¨æ·æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | int successNum = 0; |
| | | int failureNum = 0; |
| | | StringBuilder successMsg = new StringBuilder(); |
| | | StringBuilder failureMsg = new StringBuilder(); |
| | | String password = configService.selectConfigByKey("sys.user.initPassword"); |
| | | for (SysUser user : userList) { |
| | | try { |
| | | // éªè¯æ¯å¦åå¨è¿ä¸ªç¨æ· |
| | | SysUser u = baseMapper.selectUserByUserName(user.getUserName()); |
| | | if (StringUtils.isNull(u)) { |
| | | user.setPassword(SecurityUtils.encryptPassword(password)); |
| | | user.setCreateBy(operName); |
| | | this.insertUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>" + successNum + "ãè´¦å· " + user.getUserName() + " 导å
¥æå"); |
| | | } else if (isUpdateSupport) { |
| | | user.setUpdateBy(operName); |
| | | this.updateUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>" + successNum + "ãè´¦å· " + user.getUserName() + " æ´æ°æå"); |
| | | } else { |
| | | failureNum++; |
| | | failureMsg.append("<br/>" + failureNum + "ãè´¦å· " + user.getUserName() + " å·²åå¨"); |
| | | } |
| | | } catch (Exception e) { |
| | | failureNum++; |
| | | String msg = "<br/>" + failureNum + "ãè´¦å· " + user.getUserName() + " 导å
¥å¤±è´¥ï¼"; |
| | | failureMsg.append(msg + e.getMessage()); |
| | | log.error(msg, e); |
| | | } |
| | | } |
| | | if (failureNum > 0) { |
| | | failureMsg.insert(0, "徿±æï¼å¯¼å
¥å¤±è´¥ï¼å
± " + failureNum + " æ¡æ°æ®æ ¼å¼ä¸æ£ç¡®ï¼é误å¦ä¸ï¼"); |
| | | throw new ServiceException(failureMsg.toString()); |
| | | } else { |
| | | successMsg.insert(0, "æåæ¨ï¼æ°æ®å·²å
¨é¨å¯¼å
¥æåï¼å
± " + successNum + " æ¡ï¼æ°æ®å¦ä¸ï¼"); |
| | | } |
| | | return successMsg.toString(); |
| | | } |
| | | } |
| | |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | <!-- æ°æ®èå´è¿æ»¤ --> |
| | | <if test="params.dataScope != null and params.dataScope != ''"> |
| | | AND ( ${params.dataScope} ) |
| | | </if> |
| | | <!-- <!– æ°æ®èå´è¿æ»¤ –>--> |
| | | <!-- <if test="params.dataScope != null and params.dataScope != ''">--> |
| | | <!-- AND ( ${params.dataScope} )--> |
| | | <!-- </if>--> |
| | | order by d.parent_id, d.order_num |
| | | </select> |
| | | |
| | | <select id="selectDeptListByRoleId" resultType="Integer"> |
| | | <select id="selectDeptListByRoleId" resultType="Long"> |
| | | select d.dept_id |
| | | from sys_dept d |
| | | left join sys_role_dept rd on d.dept_id = rd.dept_id |
| | | left join sys_role_dept rd on d.dept_id = rd.dept_id |
| | | where rd.role_id = #{roleId} |
| | | <if test="deptCheckStrictly"> |
| | | and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId}) |
| | |
| | | <result property="remark" column="remark"/> |
| | | </resultMap> |
| | | |
| | | <sql id="selectMenuVo"> |
| | | select menu_id, |
| | | menu_name, |
| | | parent_id, |
| | | order_num, |
| | | path, |
| | | component, |
| | | query, |
| | | is_frame, |
| | | is_cache, |
| | | menu_type, |
| | | visible, |
| | | status, |
| | | ifnull(perms, '') as perms, |
| | | icon, |
| | | create_time |
| | | from sys_menu |
| | | </sql> |
| | | |
| | | |
| | | <select id="selectMenuTreeAll" resultMap="SysMenuResult"> |
| | | select distinct m.menu_id, |
| | | m.parent_id, |
| | | m.menu_name, |
| | | m.path, |
| | | m.component, |
| | | m.query, |
| | | m.`query`, |
| | | m.visible, |
| | | m.status, |
| | | ifnull(m.perms, '') as perms, |
| | |
| | | </select> |
| | | |
| | | <select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult"> |
| | | select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, |
| | | select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, |
| | | ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time |
| | | from sys_menu m |
| | | left join sys_role_menu rm on m.menu_id = rm.menu_id |
| | |
| | | m.menu_name, |
| | | m.path, |
| | | m.component, |
| | | m.query, |
| | | m.`query`, |
| | | m.visible, |
| | | m.status, |
| | | ifnull(m.perms, '') as perms, |
| | |
| | | from sys_post |
| | | </sql> |
| | | |
| | | <select id="selectPostListByUserId" parameterType="Long" resultType="Integer"> |
| | | <select id="selectPostListByUserId" parameterType="Long" resultType="Long"> |
| | | select p.post_id |
| | | from sys_post p |
| | | left join sys_user_post up on up.post_id = p.post_id |
| | |
| | | where u.user_name = #{userName} |
| | | </select> |
| | | |
| | | </mapper> |
| | | </mapper> |
| | |
| | | <if test="role.params.endTime != null and role.params.endTime != ''"><!-- ç»ææ¶é´æ£ç´¢ --> |
| | | and date_format(r.create_time,'%y%m%d') <= date_format(#{role.params.endTime},'%y%m%d') |
| | | </if> |
| | | <!-- æ°æ®èå´è¿æ»¤ --> |
| | | <if test="role.params.dataScope != null and role.params.dataScope != ''"> |
| | | AND ( ${role.params.dataScope} ) |
| | | </if> |
| | | <!-- <!– æ°æ®èå´è¿æ»¤ –>--> |
| | | <!-- <if test="role.params.dataScope != null and role.params.dataScope != ''">--> |
| | | <!-- AND ( ${role.params.dataScope} )--> |
| | | <!-- </if>--> |
| | | order by r.role_sort |
| | | </select> |
| | | |
| | |
| | | <if test="params.endTime != null and params.endTime != ''"><!-- ç»ææ¶é´æ£ç´¢ --> |
| | | and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') |
| | | </if> |
| | | <!-- æ°æ®èå´è¿æ»¤ --> |
| | | <if test="params.dataScope != null and params.dataScope != ''"> |
| | | AND ( ${params.dataScope} ) |
| | | </if> |
| | | <!-- <!– æ°æ®èå´è¿æ»¤ –>--> |
| | | <!-- <if test="params.dataScope != null and params.dataScope != ''">--> |
| | | <!-- AND ( ${params.dataScope} )--> |
| | | <!-- </if>--> |
| | | order by r.role_sort |
| | | </select> |
| | | |
| | |
| | | AND (u.dept_id = #{user.deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{user.deptId}, |
| | | ancestors) )) |
| | | </if> |
| | | <!-- æ°æ®èå´è¿æ»¤ --> |
| | | <if test="user.params.dataScope != null and user.params.dataScope != ''"> |
| | | AND ( ${user.params.dataScope} ) |
| | | </if> |
| | | <!-- <!– æ°æ®èå´è¿æ»¤ –>--> |
| | | <!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">--> |
| | | <!-- AND ( ${user.params.dataScope} )--> |
| | | <!-- </if>--> |
| | | </select> |
| | | |
| | | <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> |
| | |
| | | AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, |
| | | ancestors) )) |
| | | </if> |
| | | <!-- æ°æ®èå´è¿æ»¤ --> |
| | | <if test="params.dataScope != null and params.dataScope != ''"> |
| | | AND ( ${params.dataScope} ) |
| | | </if> |
| | | <!-- <!– æ°æ®èå´è¿æ»¤ –>--> |
| | | <!-- <if test="params.dataScope != null and params.dataScope != ''">--> |
| | | <!-- AND ( ${params.dataScope} )--> |
| | | <!-- </if>--> |
| | | </select> |
| | | |
| | | <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> |
| | |
| | | "dependencies": { |
| | | "@riophae/vue-treeselect": "0.4.0", |
| | | "axios": "0.24.0", |
| | | "clipboard": "2.0.6", |
| | | "clipboard": "2.0.8", |
| | | "core-js": "3.19.1", |
| | | "echarts": "4.9.0", |
| | | "element-ui": "2.15.6", |
| | |
| | | "@vue/cli-plugin-eslint": "4.4.6", |
| | | "@vue/cli-service": "4.4.6", |
| | | "babel-eslint": "10.1.0", |
| | | "babel-plugin-dynamic-import-node": "2.3.3", |
| | | "chalk": "4.1.0", |
| | | "compression-webpack-plugin": "5.0.2", |
| | | "connect": "3.6.6", |
| | | "eslint": "7.15.0", |
| | | "eslint-plugin-vue": "7.2.0", |
| | |
| | | <el-form size="small"> |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="1"> |
| | | æ¥ï¼å
许çéé
符[, - * / L M] |
| | | æ¥ï¼å
许çéé
符[, - * ? / L W] |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="3"> |
| | | å¨æä» |
| | | <el-input-number v-model='cycle01' :min="0" :max="31" /> - |
| | | <el-input-number v-model='cycle02' :min="0" :max="31" /> æ¥ |
| | | <el-input-number v-model='cycle01' :min="1" :max="30" /> - |
| | | <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 2" :max="31" /> æ¥ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="4"> |
| | | ä» |
| | | <el-input-number v-model='average01' :min="0" :max="31" /> å·å¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="0" :max="31" /> æ¥æ§è¡ä¸æ¬¡ |
| | | <el-input-number v-model='average01' :min="1" :max="30" /> å·å¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="1" :max="31 - average01 || 1" /> æ¥æ§è¡ä¸æ¬¡ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="5"> |
| | | æ¯æ |
| | | <el-input-number v-model='workday' :min="0" :max="31" /> å·æè¿çé£ä¸ªå·¥ä½æ¥ |
| | | <el-input-number v-model='workday' :min="1" :max="31" /> å·æè¿çé£ä¸ªå·¥ä½æ¥ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | // åéæé®å¼ååæ¶ |
| | | radioChange() { |
| | | ('day rachange'); |
| | | if (this.radioValue === 1) { |
| | | this.$emit('update', 'day', '*', 'day'); |
| | | this.$emit('update', 'week', '?', 'day'); |
| | | this.$emit('update', 'month', '*', 'day'); |
| | | } else { |
| | | if (this.cron.hour === '*') { |
| | | this.$emit('update', 'hour', '0', 'day'); |
| | | } |
| | | if (this.cron.min === '*') { |
| | | this.$emit('update', 'min', '0', 'day'); |
| | | } |
| | | if (this.cron.second === '*') { |
| | | this.$emit('update', 'second', '0', 'day'); |
| | | } |
| | | if (this.radioValue !== 2 && this.cron.week !== '?') { |
| | | this.$emit('update', 'week', '?', 'day') |
| | | } |
| | | |
| | | switch (this.radioValue) { |
| | | case 1: |
| | | this.$emit('update', 'day', '*'); |
| | | break; |
| | | case 2: |
| | | this.$emit('update', 'day', '?'); |
| | | break; |
| | | case 3: |
| | | this.$emit('update', 'day', this.cycle01 + '-' + this.cycle02); |
| | | this.$emit('update', 'day', this.cycleTotal); |
| | | break; |
| | | case 4: |
| | | this.$emit('update', 'day', this.average01 + '/' + this.average02); |
| | | this.$emit('update', 'day', this.averageTotal); |
| | | break; |
| | | case 5: |
| | | this.$emit('update', 'day', this.workday + 'W'); |
| | |
| | | // æè¿å·¥ä½æ¥å¼ååæ¶ |
| | | workdayChange() { |
| | | if (this.radioValue == '5') { |
| | | this.$emit('update', 'day', this.workday + 'W'); |
| | | this.$emit('update', 'day', this.workdayCheck + 'W'); |
| | | } |
| | | }, |
| | | // checkboxå¼ååæ¶ |
| | |
| | | if (this.radioValue == '7') { |
| | | this.$emit('update', 'day', this.checkboxString); |
| | | } |
| | | }, |
| | | // ç¶ç»ä»¶ä¼ éçweekåçåå触å |
| | | weekChange() { |
| | | //夿weekå¼ä¸dayä¸è½åæ¶ä¸ºâ?â |
| | | if (this.cron.week == '?' && this.radioValue == '2') { |
| | | this.radioValue = '1'; |
| | | } else if (this.cron.week !== '?' && this.radioValue != '2') { |
| | | this.radioValue = '2'; |
| | | } |
| | | }, |
| | | } |
| | | }, |
| | | watch: { |
| | | "radioValue": "radioChange", |
| | | 'radioValue': 'radioChange', |
| | | 'cycleTotal': 'cycleChange', |
| | | 'averageTotal': 'averageChange', |
| | | 'workdayCheck': 'workdayChange', |
| | |
| | | computed: { |
| | | // 计ç®ä¸¤ä¸ªå¨æå¼ |
| | | cycleTotal: function () { |
| | | this.cycle01 = this.checkNum(this.cycle01, 1, 31) |
| | | this.cycle02 = this.checkNum(this.cycle02, 1, 31) |
| | | return this.cycle01 + '-' + this.cycle02; |
| | | const cycle01 = this.checkNum(this.cycle01, 1, 30) |
| | | const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 2, 31, 31) |
| | | return cycle01 + '-' + cycle02; |
| | | }, |
| | | // 计ç®å¹³åç¨å°çå¼ |
| | | averageTotal: function () { |
| | | this.average01 = this.checkNum(this.average01, 1, 31) |
| | | this.average02 = this.checkNum(this.average02, 1, 31) |
| | | return this.average01 + '/' + this.average02; |
| | | const average01 = this.checkNum(this.average01, 1, 30) |
| | | const average02 = this.checkNum(this.average02, 1, 31 - average01 || 0) |
| | | return average01 + '/' + average02; |
| | | }, |
| | | // 计ç®å·¥ä½æ¥æ ¼å¼ |
| | | workdayCheck: function () { |
| | | this.workday = this.checkNum(this.workday, 1, 31) |
| | | return this.workday; |
| | | const workday = this.checkNum(this.workday, 1, 31) |
| | | return workday; |
| | | }, |
| | | // 计ç®å¾éçcheckboxå¼åé |
| | | checkboxString: function () { |
| | |
| | | <el-form-item>
|
| | | <el-radio v-model='radioValue' :label="2">
|
| | | 卿ä»
|
| | | <el-input-number v-model='cycle01' :min="0" :max="60" /> -
|
| | | <el-input-number v-model='cycle02' :min="0" :max="60" /> å°æ¶
|
| | | <el-input-number v-model='cycle01' :min="0" :max="22" /> -
|
| | | <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="23" /> å°æ¶
|
| | | </el-radio>
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item>
|
| | | <el-radio v-model='radioValue' :label="3">
|
| | | ä»
|
| | | <el-input-number v-model='average01' :min="0" :max="60" /> å°æ¶å¼å§ï¼æ¯
|
| | | <el-input-number v-model='average02' :min="0" :max="60" /> å°æ¶æ§è¡ä¸æ¬¡
|
| | | <el-input-number v-model='average01' :min="0" :max="22" /> å°æ¶å¼å§ï¼æ¯
|
| | | <el-input-number v-model='average02' :min="1" :max="23 - average01 || 0" /> å°æ¶æ§è¡ä¸æ¬¡
|
| | | </el-radio>
|
| | | </el-form-item>
|
| | |
|
| | |
| | | methods: {
|
| | | // åéæé®å¼ååæ¶
|
| | | radioChange() {
|
| | | if (this.radioValue === 1) {
|
| | | this.$emit('update', 'hour', '*', 'hour');
|
| | | this.$emit('update', 'day', '*', 'hour');
|
| | | } else {
|
| | | if (this.cron.min === '*') {
|
| | | this.$emit('update', 'min', '0', 'hour');
|
| | | }
|
| | | if (this.cron.second === '*') {
|
| | | this.$emit('update', 'second', '0', 'hour');
|
| | | }
|
| | | }
|
| | | switch (this.radioValue) {
|
| | | case 1:
|
| | | this.$emit('update', 'hour', '*')
|
| | | break;
|
| | | case 2:
|
| | | this.$emit('update', 'hour', this.cycle01 + '-' + this.cycle02);
|
| | | this.$emit('update', 'hour', this.cycleTotal);
|
| | | break;
|
| | | case 3:
|
| | | this.$emit('update', 'hour', this.average01 + '/' + this.average02);
|
| | | this.$emit('update', 'hour', this.averageTotal);
|
| | | break;
|
| | | case 4:
|
| | | this.$emit('update', 'hour', this.checkboxString);
|
| | |
| | | }
|
| | | },
|
| | | watch: {
|
| | | "radioValue": "radioChange",
|
| | | 'radioValue': 'radioChange',
|
| | | 'cycleTotal': 'cycleChange',
|
| | | 'averageTotal': 'averageChange',
|
| | | 'checkboxString': 'checkboxChange'
|
| | |
| | | computed: {
|
| | | // 计ç®ä¸¤ä¸ªå¨æå¼
|
| | | cycleTotal: function () {
|
| | | this.cycle01 = this.checkNum(this.cycle01, 0, 23)
|
| | | this.cycle02 = this.checkNum(this.cycle02, 0, 23)
|
| | | return this.cycle01 + '-' + this.cycle02;
|
| | | const cycle01 = this.checkNum(this.cycle01, 0, 22)
|
| | | const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 23)
|
| | | return cycle01 + '-' + cycle02;
|
| | | },
|
| | | // 计ç®å¹³åç¨å°çå¼
|
| | | averageTotal: function () {
|
| | | this.average01 = this.checkNum(this.average01, 0, 23)
|
| | | this.average02 = this.checkNum(this.average02, 1, 23)
|
| | | return this.average01 + '/' + this.average02;
|
| | | const average01 = this.checkNum(this.average01, 0, 22)
|
| | | const average02 = this.checkNum(this.average02, 1, 23 - average01 || 0)
|
| | | return average01 + '/' + average02;
|
| | | },
|
| | | // 计ç®å¾éçcheckboxå¼åé
|
| | | checkboxString: function () {
|
| | |
| | | <div> |
| | | <el-tabs type="border-card"> |
| | | <el-tab-pane label="ç§" v-if="shouldHide('second')"> |
| | | <CrontabSecond @update="updateCrontabValue" :check="checkNumber" ref="cronsecond" /> |
| | | <CrontabSecond |
| | | @update="updateCrontabValue" |
| | | :check="checkNumber" |
| | | :cron="crontabValueObj" |
| | | ref="cronsecond" |
| | | /> |
| | | </el-tab-pane> |
| | | |
| | | <el-tab-pane label="åé" v-if="shouldHide('min')"> |
| | |
| | | insValue = 5; |
| | | } else { |
| | | this.$refs[refName].checkboxList = value.split(","); |
| | | insValue = 7; |
| | | insValue = 6; |
| | | } |
| | | } else if (name == "year") { |
| | | if (value == "") { |
| | |
| | | <el-form-item>
|
| | | <el-radio v-model='radioValue' :label="2">
|
| | | 卿ä»
|
| | | <el-input-number v-model='cycle01' :min="0" :max="60" /> -
|
| | | <el-input-number v-model='cycle02' :min="0" :max="60" /> åé
|
| | | <el-input-number v-model='cycle01' :min="0" :max="58" /> -
|
| | | <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="59" /> åé
|
| | | </el-radio>
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item>
|
| | | <el-radio v-model='radioValue' :label="3">
|
| | | ä»
|
| | | <el-input-number v-model='average01' :min="0" :max="60" /> åéå¼å§ï¼æ¯
|
| | | <el-input-number v-model='average02' :min="0" :max="60" /> åéæ§è¡ä¸æ¬¡
|
| | | <el-input-number v-model='average01' :min="0" :max="58" /> åéå¼å§ï¼æ¯
|
| | | <el-input-number v-model='average02' :min="1" :max="59 - average01 || 0" /> åéæ§è¡ä¸æ¬¡
|
| | | </el-radio>
|
| | | </el-form-item>
|
| | |
|
| | |
| | | methods: {
|
| | | // åéæé®å¼ååæ¶
|
| | | radioChange() {
|
| | | if (this.radioValue !== 1 && this.cron.second === '*') {
|
| | | this.$emit('update', 'second', '0', 'min');
|
| | | }
|
| | | switch (this.radioValue) {
|
| | | case 1:
|
| | | this.$emit('update', 'min', '*', 'min');
|
| | | this.$emit('update', 'hour', '*', 'min');
|
| | | break;
|
| | | case 2:
|
| | | this.$emit('update', 'min', this.cycle01 + '-' + this.cycle02, 'min');
|
| | | this.$emit('update', 'min', this.cycleTotal, 'min');
|
| | | break;
|
| | | case 3:
|
| | | this.$emit('update', 'min', this.average01 + '/' + this.average02, 'min');
|
| | | this.$emit('update', 'min', this.averageTotal, 'min');
|
| | | break;
|
| | | case 4:
|
| | | this.$emit('update', 'min', this.checkboxString, 'min');
|
| | |
| | |
|
| | | },
|
| | | watch: {
|
| | | "radioValue": "radioChange",
|
| | | 'radioValue': 'radioChange',
|
| | | 'cycleTotal': 'cycleChange',
|
| | | 'averageTotal': 'averageChange',
|
| | | 'checkboxString': 'checkboxChange',
|
| | |
| | | computed: {
|
| | | // 计ç®ä¸¤ä¸ªå¨æå¼
|
| | | cycleTotal: function () {
|
| | | this.cycle01 = this.checkNum(this.cycle01, 0, 59)
|
| | | this.cycle02 = this.checkNum(this.cycle02, 0, 59)
|
| | | return this.cycle01 + '-' + this.cycle02;
|
| | | const cycle01 = this.checkNum(this.cycle01, 0, 58)
|
| | | const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 59)
|
| | | return cycle01 + '-' + cycle02;
|
| | | },
|
| | | // 计ç®å¹³åç¨å°çå¼
|
| | | averageTotal: function () {
|
| | | this.average01 = this.checkNum(this.average01, 0, 59)
|
| | | this.average02 = this.checkNum(this.average02, 1, 59)
|
| | | return this.average01 + '/' + this.average02;
|
| | | const average01 = this.checkNum(this.average01, 0, 58)
|
| | | const average02 = this.checkNum(this.average02, 1, 59 - average01 || 0)
|
| | | return average01 + '/' + average02;
|
| | | },
|
| | | // 计ç®å¾éçcheckboxå¼åé
|
| | | checkboxString: function () {
|
| | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="2"> |
| | | å¨æä» |
| | | <el-input-number v-model='cycle01' :min="1" :max="12" /> - |
| | | <el-input-number v-model='cycle02' :min="1" :max="12" /> æ |
| | | <el-input-number v-model='cycle01' :min="1" :max="11" /> - |
| | | <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 2" :max="12" /> æ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="3"> |
| | | ä» |
| | | <el-input-number v-model='average01' :min="1" :max="12" /> æå¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="1" :max="12" /> æææ§è¡ä¸æ¬¡ |
| | | <el-input-number v-model='average01' :min="1" :max="11" /> æå¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="1" :max="12 - average01 || 0" /> æææ§è¡ä¸æ¬¡ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | methods: { |
| | | // åéæé®å¼ååæ¶ |
| | | radioChange() { |
| | | if (this.radioValue === 1) { |
| | | this.$emit('update', 'month', '*'); |
| | | this.$emit('update', 'year', '*'); |
| | | } else { |
| | | if (this.cron.day === '*') { |
| | | this.$emit('update', 'day', '0', 'month'); |
| | | } |
| | | if (this.cron.hour === '*') { |
| | | this.$emit('update', 'hour', '0', 'month'); |
| | | } |
| | | if (this.cron.min === '*') { |
| | | this.$emit('update', 'min', '0', 'month'); |
| | | } |
| | | if (this.cron.second === '*') { |
| | | this.$emit('update', 'second', '0', 'month'); |
| | | } |
| | | } |
| | | switch (this.radioValue) { |
| | | case 1: |
| | | this.$emit('update', 'month', '*'); |
| | | break; |
| | | case 2: |
| | | this.$emit('update', 'month', this.cycle01 + '-' + this.cycle02); |
| | | this.$emit('update', 'month', this.cycleTotal); |
| | | break; |
| | | case 3: |
| | | this.$emit('update', 'month', this.average01 + '/' + this.average02); |
| | | this.$emit('update', 'month', this.averageTotal); |
| | | break; |
| | | case 4: |
| | | this.$emit('update', 'month', this.checkboxString); |
| | |
| | | } |
| | | }, |
| | | watch: { |
| | | "radioValue": "radioChange", |
| | | 'radioValue': 'radioChange', |
| | | 'cycleTotal': 'cycleChange', |
| | | 'averageTotal': 'averageChange', |
| | | 'checkboxString': 'checkboxChange' |
| | |
| | | computed: { |
| | | // 计ç®ä¸¤ä¸ªå¨æå¼ |
| | | cycleTotal: function () { |
| | | this.cycle01 = this.checkNum(this.cycle01, 1, 12) |
| | | this.cycle02 = this.checkNum(this.cycle02, 1, 12) |
| | | return this.cycle01 + '-' + this.cycle02; |
| | | const cycle01 = this.checkNum(this.cycle01, 1, 11) |
| | | const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 2, 12) |
| | | return cycle01 + '-' + cycle02; |
| | | }, |
| | | // 计ç®å¹³åç¨å°çå¼ |
| | | averageTotal: function () { |
| | | this.average01 = this.checkNum(this.average01, 1, 12) |
| | | this.average02 = this.checkNum(this.average02, 1, 12) |
| | | return this.average01 + '/' + this.average02; |
| | | const average01 = this.checkNum(this.average01, 1, 11) |
| | | const average02 = this.checkNum(this.average02, 1, 12 - average01 || 0) |
| | | return average01 + '/' + average02; |
| | | }, |
| | | // 计ç®å¾éçcheckboxå¼åé |
| | | checkboxString: function () { |
| | |
| | | // è·åè¾¾å°æ¡ä»¶çæ¥ææ¯ææX |
| | | let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week'); |
| | | // å½æææ¥æ¶ |
| | | if (thisWeek == 0) { |
| | | if (thisWeek == 1) { |
| | | // å
æ¾ä¸ä¸ä¸ªæ¥ï¼å¹¶å¤ææ¯å¦ä¸ºæåº |
| | | DD++; |
| | | thisDD = DD < 10 ? '0' + DD : DD; |
| | |
| | | if (this.checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { |
| | | DD -= 3; |
| | | } |
| | | } else if (thisWeek == 6) { |
| | | } else if (thisWeek == 7) { |
| | | // 彿æ6æ¶åªé夿䏿¯1å·å°±å¯è¿è¡æä½ |
| | | if (this.dayRuleSup !== 1) { |
| | | DD--; |
| | |
| | | // è·åå½åæ¥ææ¯å±äºææå |
| | | let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week'); |
| | | // æ ¡éªå½åæææ¯å¦å¨æææ± ï¼dayRuleSupï¼ä¸ |
| | | if (Array.indexOf(this.dayRuleSup, thisWeek) < 0) { |
| | | if (this.dayRuleSup.indexOf(thisWeek) < 0) { |
| | | // 妿å°è¾¾æå¤§å¼æ¶ |
| | | if (Di == DDate.length - 1) { |
| | | resetDay(); |
| | |
| | | } else if (rule.indexOf('#') >= 0) { |
| | | this.dayRule = 'assWeek'; |
| | | let matchRule = rule.match(/[0-9]{1}/g); |
| | | this.dayRuleSup = [Number(matchRule[0]), Number(matchRule[1])]; |
| | | this.dayRuleSup = [Number(matchRule[1]), Number(matchRule[0])]; |
| | | this.dateArr[3] = [1]; |
| | | if (this.dayRuleSup[1] == 7) { |
| | | this.dayRuleSup[1] = 0; |
| | |
| | | } else if (rule !== '*' && rule !== '?') { |
| | | this.dayRule = 'weekDay'; |
| | | this.dayRuleSup = this.getAssignArr(rule) |
| | | } |
| | | // 妿weekDayæ¶å°7è°æ´ä¸º0ãweekå¼0峿¯æææ¥ã |
| | | if (this.dayRule == 'weekDay') { |
| | | for (let i = 0; i < this.dayRuleSup.length; i++) { |
| | | if (this.dayRuleSup[i] == 7) { |
| | | this.dayRuleSup[i] = 0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | if (type == undefined) { |
| | | return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); |
| | | } else if (type == 'week') { |
| | | return week; |
| | | // å¨quartzä¸ 1ä¸ºæææ¥ |
| | | return week + 1; |
| | | } |
| | | }, |
| | | // æ£æ¥æ¥ææ¯å¦åå¨ |
| | | checkDate(value) { |
| | | let time = new Date(value); |
| | | let format = this.formatDate(time) |
| | | return value == format ? true : false; |
| | | return value === format; |
| | | } |
| | | }, |
| | | watch: { |
| | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="2"> |
| | | å¨æä» |
| | | <el-input-number v-model='cycle01' :min="0" :max="60" /> - |
| | | <el-input-number v-model='cycle02' :min="0" :max="60" /> ç§ |
| | | <el-input-number v-model='cycle01' :min="0" :max="58" /> - |
| | | <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="59" /> ç§ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="3"> |
| | | ä» |
| | | <el-input-number v-model='average01' :min="0" :max="60" /> ç§å¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="0" :max="60" /> ç§æ§è¡ä¸æ¬¡ |
| | | <el-input-number v-model='average01' :min="0" :max="58" /> ç§å¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="1" :max="59 - average01 || 0" /> ç§æ§è¡ä¸æ¬¡ |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | switch (this.radioValue) { |
| | | case 1: |
| | | this.$emit('update', 'second', '*', 'second'); |
| | | this.$emit('update', 'min', '*', 'second'); |
| | | break; |
| | | case 2: |
| | | this.$emit('update', 'second', this.cycle01 + '-' + this.cycle02); |
| | | this.$emit('update', 'second', this.cycleTotal); |
| | | break; |
| | | case 3: |
| | | this.$emit('update', 'second', this.average01 + '/' + this.average02); |
| | | this.$emit('update', 'second', this.averageTotal); |
| | | break; |
| | | case 4: |
| | | this.$emit('update', 'second', this.checkboxString); |
| | |
| | | if (this.radioValue == '4') { |
| | | this.$emit('update', 'second', this.checkboxString); |
| | | } |
| | | }, |
| | | othChange() { |
| | | // åè§£æ |
| | | let ins = this.cron.second |
| | | ('åè§£æ second', ins); |
| | | if (ins === '*') { |
| | | this.radioValue = 1; |
| | | } else if (ins.indexOf('-') > -1) { |
| | | this.radioValue = 2 |
| | | } else if (ins.indexOf('/') > -1) { |
| | | this.radioValue = 3 |
| | | } else { |
| | | this.radioValue = 4 |
| | | this.checkboxList = ins.split(',') |
| | | } |
| | | } |
| | | }, |
| | | watch: { |
| | | "radioValue": "radioChange", |
| | | 'radioValue': 'radioChange', |
| | | 'cycleTotal': 'cycleChange', |
| | | 'averageTotal': 'averageChange', |
| | | 'checkboxString': 'checkboxChange', |
| | |
| | | computed: { |
| | | // 计ç®ä¸¤ä¸ªå¨æå¼ |
| | | cycleTotal: function () { |
| | | this.cycle01 = this.checkNum(this.cycle01, 0, 59) |
| | | this.cycle02 = this.checkNum(this.cycle02, 0, 59) |
| | | return this.cycle01 + '-' + this.cycle02; |
| | | const cycle01 = this.checkNum(this.cycle01, 0, 58) |
| | | const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 59) |
| | | return cycle01 + '-' + cycle02; |
| | | }, |
| | | // 计ç®å¹³åç¨å°çå¼ |
| | | averageTotal: function () { |
| | | this.average01 = this.checkNum(this.average01, 0, 59) |
| | | this.average02 = this.checkNum(this.average02, 1, 59) |
| | | return this.average01 + '/' + this.average02; |
| | | const average01 = this.checkNum(this.average01, 0, 58) |
| | | const average02 = this.checkNum(this.average02, 1, 59 - average01 || 0) |
| | | return average01 + '/' + average02; |
| | | }, |
| | | // 计ç®å¾éçcheckboxå¼åé |
| | | checkboxString: function () { |
| | |
| | | <el-form size='small'> |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="1"> |
| | | å¨ï¼å
许çéé
符[, - * / L #] |
| | | å¨ï¼å
许çéé
符[, - * ? / L #] |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="3"> |
| | | 卿仿æ |
| | | <el-input-number v-model='cycle01' :min="1" :max="7" /> - |
| | | <el-input-number v-model='cycle02' :min="1" :max="7" /> |
| | | <el-select clearable v-model="cycle01"> |
| | | <el-option |
| | | v-for="(item,index) of weekList" |
| | | :key="index" |
| | | :label="item.value" |
| | | :value="item.key" |
| | | :disabled="item.key === 1" |
| | | >{{item.value}}</el-option> |
| | | </el-select> |
| | | - |
| | | <el-select clearable v-model="cycle02"> |
| | | <el-option |
| | | v-for="(item,index) of weekList" |
| | | :key="index" |
| | | :label="item.value" |
| | | :value="item.key" |
| | | :disabled="item.key < cycle01 && item.key !== 1" |
| | | >{{item.value}}</el-option> |
| | | </el-select> |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | <el-radio v-model='radioValue' :label="4"> |
| | | 第 |
| | | <el-input-number v-model='average01' :min="1" :max="4" /> å¨çææ |
| | | <el-input-number v-model='average02' :min="1" :max="7" /> |
| | | <el-select clearable v-model="average02"> |
| | | <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option> |
| | | </el-select> |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-radio v-model='radioValue' :label="5"> |
| | | æ¬ææåä¸ä¸ªææ |
| | | <el-input-number v-model='weekday' :min="1" :max="7" /> |
| | | <el-select clearable v-model="weekday"> |
| | | <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option> |
| | | </el-select> |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | |
| | | <el-radio v-model='radioValue' :label="6"> |
| | | æå® |
| | | <el-select clearable v-model="checkboxList" placeholder="å¯å¤é" multiple style="width:100%"> |
| | | <el-option v-for="(item,index) of weekList" :key="index" :value="index+1">{{item}}</el-option> |
| | | <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="String(item.key)">{{item.value}}</el-option> |
| | | </el-select> |
| | | </el-radio> |
| | | </el-form-item> |
| | |
| | | data() { |
| | | return { |
| | | radioValue: 2, |
| | | weekday: 1, |
| | | cycle01: 1, |
| | | cycle02: 2, |
| | | weekday: 2, |
| | | cycle01: 2, |
| | | cycle02: 3, |
| | | average01: 1, |
| | | average02: 1, |
| | | average02: 2, |
| | | checkboxList: [], |
| | | weekList: ['å¨ä¸', 'å¨äº', 'å¨ä¸', 'å¨å', 'å¨äº', 'å¨å
', '卿¥'], |
| | | weekList: [ |
| | | { |
| | | key: 2, |
| | | value: 'ææä¸' |
| | | }, |
| | | { |
| | | key: 3, |
| | | value: 'ææäº' |
| | | }, |
| | | { |
| | | key: 4, |
| | | value: 'ææä¸' |
| | | }, |
| | | { |
| | | key: 5, |
| | | value: 'ææå' |
| | | }, |
| | | { |
| | | key: 6, |
| | | value: 'ææäº' |
| | | }, |
| | | { |
| | | key: 7, |
| | | value: 'ææå
' |
| | | }, |
| | | { |
| | | key: 1, |
| | | value: 'æææ¥' |
| | | } |
| | | ], |
| | | checkNum: this.$options.propsData.check |
| | | } |
| | | }, |
| | |
| | | methods: { |
| | | // åéæé®å¼ååæ¶ |
| | | radioChange() { |
| | | if (this.radioValue === 1) { |
| | | this.$emit('update', 'week', '*'); |
| | | this.$emit('update', 'year', '*'); |
| | | } else { |
| | | if (this.cron.month === '*') { |
| | | this.$emit('update', 'month', '0', 'week'); |
| | | } |
| | | if (this.cron.day === '*') { |
| | | this.$emit('update', 'day', '0', 'week'); |
| | | } |
| | | if (this.cron.hour === '*') { |
| | | this.$emit('update', 'hour', '0', 'week'); |
| | | } |
| | | if (this.cron.min === '*') { |
| | | this.$emit('update', 'min', '0', 'week'); |
| | | } |
| | | if (this.cron.second === '*') { |
| | | this.$emit('update', 'second', '0', 'week'); |
| | | } |
| | | if (this.radioValue !== 2 && this.cron.day !== '?') { |
| | | this.$emit('update', 'day', '?', 'week'); |
| | | } |
| | | switch (this.radioValue) { |
| | | case 1: |
| | | this.$emit('update', 'week', '*'); |
| | | break; |
| | | case 2: |
| | | this.$emit('update', 'week', '?'); |
| | | break; |
| | | case 3: |
| | | this.$emit('update', 'week', this.cycle01 + '-' + this.cycle02); |
| | | this.$emit('update', 'week', this.cycleTotal); |
| | | break; |
| | | case 4: |
| | | this.$emit('update', 'week', this.average01 + '#' + this.average02); |
| | | this.$emit('update', 'week', this.averageTotal); |
| | | break; |
| | | case 5: |
| | | this.$emit('update', 'week', this.weekday + 'L'); |
| | | this.$emit('update', 'week', this.weekdayCheck + 'L'); |
| | | break; |
| | | case 6: |
| | | this.$emit('update', 'week', this.checkboxString); |
| | | break; |
| | | } |
| | | }, |
| | | // æ ¹æ®äºæ¥äºä»¶ï¼æ´æ¹radioçå¼ |
| | | |
| | | // å¨æä¸¤ä¸ªå¼ååæ¶ |
| | | cycleChange() { |
| | |
| | | }, |
| | | }, |
| | | watch: { |
| | | "radioValue": "radioChange", |
| | | 'radioValue': 'radioChange', |
| | | 'cycleTotal': 'cycleChange', |
| | | 'averageTotal': 'averageChange', |
| | | 'weekdayCheck': 'weekdayChange', |
| | |
| | | averageTotal: function () { |
| | | this.average01 = this.checkNum(this.average01, 1, 4) |
| | | this.average02 = this.checkNum(this.average02, 1, 7) |
| | | return this.average01 + '#' + this.average02; |
| | | return this.average02 + '#' + this.average01; |
| | | }, |
| | | // æè¿ç工使¥ï¼æ ¼å¼ï¼ |
| | | weekdayCheck: function () { |
| | |
| | | <el-form-item> |
| | | <el-radio :label="3" v-model='radioValue'> |
| | | å¨æä» |
| | | <el-input-number v-model='cycle01' :min='fullYear' /> - |
| | | <el-input-number v-model='cycle02' :min='fullYear' /> |
| | | <el-input-number v-model='cycle01' :min='fullYear' :max="2098" /> - |
| | | <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : fullYear + 1" :max="2099" /> |
| | | </el-radio> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-radio :label="4" v-model='radioValue'> |
| | | ä» |
| | | <el-input-number v-model='average01' :min='fullYear' /> å¹´å¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min='fullYear' /> å¹´æ§è¡ä¸æ¬¡ |
| | | <el-input-number v-model='average01' :min='fullYear' :max="2098"/> å¹´å¼å§ï¼æ¯ |
| | | <el-input-number v-model='average02' :min="1" :max="2099 - average01 || fullYear" /> å¹´æ§è¡ä¸æ¬¡ |
| | | </el-radio> |
| | | |
| | | </el-form-item> |
| | |
| | | methods: { |
| | | // åéæé®å¼ååæ¶ |
| | | radioChange() { |
| | | if (this.cron.month === '*') { |
| | | this.$emit('update', 'month', '0', 'year'); |
| | | } |
| | | if (this.cron.day === '*') { |
| | | this.$emit('update', 'day', '0', 'year'); |
| | | } |
| | | if (this.cron.hour === '*') { |
| | | this.$emit('update', 'hour', '0', 'year'); |
| | | } |
| | | if (this.cron.min === '*') { |
| | | this.$emit('update', 'min', '0', 'year'); |
| | | } |
| | | if (this.cron.second === '*') { |
| | | this.$emit('update', 'second', '0', 'year'); |
| | | } |
| | | switch (this.radioValue) { |
| | | case 1: |
| | | this.$emit('update', 'year', ''); |
| | |
| | | this.$emit('update', 'year', '*'); |
| | | break; |
| | | case 3: |
| | | this.$emit('update', 'year', this.cycle01 + '-' + this.cycle02); |
| | | this.$emit('update', 'year', this.cycleTotal); |
| | | break; |
| | | case 4: |
| | | this.$emit('update', 'year', this.average01 + '/' + this.average02); |
| | | this.$emit('update', 'year', this.averageTotal); |
| | | break; |
| | | case 5: |
| | | this.$emit('update', 'year', this.checkboxString); |
| | |
| | | } |
| | | }, |
| | | watch: { |
| | | "radioValue": "radioChange", |
| | | 'radioValue': 'radioChange', |
| | | 'cycleTotal': 'cycleChange', |
| | | 'averageTotal': 'averageChange', |
| | | 'checkboxString': 'checkboxChange' |
| | |
| | | computed: { |
| | | // 计ç®ä¸¤ä¸ªå¨æå¼ |
| | | cycleTotal: function () { |
| | | this.cycle01 = this.checkNum(this.cycle01, this.fullYear, this.fullYear + 100) |
| | | this.cycle02 = this.checkNum(this.cycle02, this.fullYear + 1, this.fullYear + 101) |
| | | return this.cycle01 + '-' + this.cycle02; |
| | | const cycle01 = this.checkNum(this.cycle01, this.fullYear, 2098) |
| | | const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : this.fullYear + 1, 2099) |
| | | return cycle01 + '-' + cycle02; |
| | | }, |
| | | // 计ç®å¹³åç¨å°çå¼ |
| | | averageTotal: function () { |
| | | this.average01 = this.checkNum(this.average01, this.fullYear, this.fullYear + 100) |
| | | this.average02 = this.checkNum(this.average02, 1, 10) |
| | | return this.average01 + '/' + this.average02; |
| | | const average01 = this.checkNum(this.average01, this.fullYear, 2098) |
| | | const average02 = this.checkNum(this.average02, 1, 2099 - average01 || this.fullYear) |
| | | return average01 + '/' + average02; |
| | | }, |
| | | // 计ç®å¾éçcheckboxå¼åé |
| | | checkboxString: function () { |
| | |
| | | mounted: function () { |
| | | // ä»
è·åå½å年份 |
| | | this.fullYear = Number(new Date().getFullYear()); |
| | | this.cycle01 = this.fullYear |
| | | this.average01 = this.fullYear |
| | | } |
| | | } |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-image :src="`${realSrc}`" fit="cover" :style="`width:${realWidth};height:${realHeight};`" :preview-src-list="[`${realSrc}`]"> |
| | | <div slot="error" class="image-slot"> |
| | | <i class="el-icon-picture-outline"></i> |
| | | </div> |
| | | </el-image> |
| | | </template> |
| | | |
| | | <script> |
| | | import { isExternal } from '@/utils/validate' |
| | | |
| | | export default { |
| | | name: 'ImagePreview', |
| | | props: { |
| | | src: { |
| | | type: String, |
| | | required: true |
| | | }, |
| | | width: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | height: { |
| | | type: [Number, String], |
| | | default: '' |
| | | } |
| | | }, |
| | | computed: { |
| | | realSrc() { |
| | | if (isExternal(this.src)) { |
| | | return this.src |
| | | } |
| | | return process.env.VUE_APP_BASE_API + this.src |
| | | }, |
| | | realWidth() { |
| | | return typeof this.width == 'string' ? this.width : `${this.width}px` |
| | | }, |
| | | realHeight() { |
| | | return typeof this.height == 'string' ? this.height : `${this.height}px` |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .el-image { |
| | | border-radius: 5px; |
| | | background-color: #ebeef5; |
| | | box-shadow: 0 0 5px 1px #ccc; |
| | | ::v-deep .el-image__inner { |
| | | transition: all 0.3s; |
| | | cursor: pointer; |
| | | &:hover { |
| | | transform: scale(1.2); |
| | | } |
| | | } |
| | | ::v-deep .image-slot { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | width: 100%; |
| | | height: 100%; |
| | | color: #909399; |
| | | font-size: 30px; |
| | | } |
| | | } |
| | | </style> |
| | |
| | | import dialogDrag from './dialog/drag' |
| | | import dialogDragWidth from './dialog/dragWidth' |
| | | import dialogDragHeight from './dialog/dragHeight' |
| | | import clipboard from './module/clipboard' |
| | | |
| | | const install = function(Vue) { |
| | | Vue.directive('hasRole', hasRole) |
| | | Vue.directive('hasPermi', hasPermi) |
| | | Vue.directive('clipboard', clipboard) |
| | | Vue.directive('dialogDrag', dialogDrag) |
| | | Vue.directive('dialogDragWidth', dialogDragWidth) |
| | | Vue.directive('dialogDragHeight', dialogDragHeight) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /** |
| | | * v-clipboard æåå¤å¶åªè´´ |
| | | * Copyright (c) 2021 ruoyi |
| | | */ |
| | | |
| | | import Clipboard from 'clipboard' |
| | | export default { |
| | | bind(el, binding, vnode) { |
| | | switch (binding.arg) { |
| | | case 'success': |
| | | el._vClipBoard_success = binding.value; |
| | | break; |
| | | case 'error': |
| | | el._vClipBoard_error = binding.value; |
| | | break; |
| | | default: { |
| | | const clipboard = new Clipboard(el, { |
| | | text: () => binding.value, |
| | | action: () => binding.arg === 'cut' ? 'cut' : 'copy' |
| | | }); |
| | | clipboard.on('success', e => { |
| | | const callback = el._vClipBoard_success; |
| | | callback && callback(e); |
| | | }); |
| | | clipboard.on('error', e => { |
| | | const callback = el._vClipBoard_error; |
| | | callback && callback(e); |
| | | }); |
| | | el._vClipBoard = clipboard; |
| | | } |
| | | } |
| | | }, |
| | | update(el, binding) { |
| | | if (binding.arg === 'success') { |
| | | el._vClipBoard_success = binding.value; |
| | | } else if (binding.arg === 'error') { |
| | | el._vClipBoard_error = binding.value; |
| | | } else { |
| | | el._vClipBoard.text = function () { return binding.value; }; |
| | | el._vClipBoard.action = () => binding.arg === 'cut' ? 'cut' : 'copy'; |
| | | } |
| | | }, |
| | | unbind(el, binding) { |
| | | if (!el._vClipboard) return |
| | | if (binding.arg === 'success') { |
| | | delete el._vClipBoard_success; |
| | | } else if (binding.arg === 'error') { |
| | | delete el._vClipBoard_error; |
| | | } else { |
| | | el._vClipBoard.destroy(); |
| | | delete el._vClipBoard; |
| | | } |
| | | } |
| | | } |
| | |
| | | import FileUpload from "@/components/FileUpload" |
| | | // å¾çä¸ä¼ ç»ä»¶ |
| | | import ImageUpload from "@/components/ImageUpload" |
| | | // å¾çé¢è§ç»ä»¶ |
| | | import ImagePreview from "@/components/ImagePreview" |
| | | // åå
¸æ ç¾ç»ä»¶ |
| | | import DictTag from '@/components/DictTag' |
| | | // 头鍿 ç¾ç»ä»¶ |
| | |
| | | Vue.component('Editor', Editor) |
| | | Vue.component('FileUpload', FileUpload) |
| | | Vue.component('ImageUpload', ImageUpload) |
| | | Vue.component('ImagePreview', ImagePreview) |
| | | |
| | | Vue.use(directive) |
| | | Vue.use(plugins) |
| | |
| | | import axios from 'axios' |
| | | import { Message } from 'element-ui' |
| | | import {Loading, Message} from 'element-ui' |
| | | import { saveAs } from 'file-saver' |
| | | import { getToken } from '@/utils/auth' |
| | | import errorCode from '@/utils/errorCode' |
| | | import { blobValidate } from "@/utils/ruoyi"; |
| | | |
| | | const baseURL = process.env.VUE_APP_BASE_API |
| | | let downloadLoadingInstance; |
| | | |
| | | export default { |
| | | oss(ossId) { |
| | | var url = baseURL + '/system/oss/download/' + ossId |
| | | downloadLoadingInstance = Loading.service({ text: "æ£å¨ä¸è½½æ°æ®ï¼è¯·ç¨å", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) |
| | | axios({ |
| | | method: 'get', |
| | | url: url, |
| | |
| | | const blob = new Blob([res.data], { type: 'application/octet-stream' }) |
| | | this.saveAs(blob, decodeURI(res.headers['download-filename'])) |
| | | } else { |
| | | Message.error('æ æçä¼è¯ï¼æè
ä¼è¯å·²è¿æï¼è¯·éæ°ç»å½ã'); |
| | | this.printErrMsg(res.data); |
| | | } |
| | | downloadLoadingInstance.close(); |
| | | }).catch((r) => { |
| | | console.error(r) |
| | | Message.error('ä¸è½½æä»¶åºç°é误ï¼è¯·è系管çåï¼') |
| | | downloadLoadingInstance.close(); |
| | | }) |
| | | }, |
| | | zip(url, name) { |
| | |
| | | const blob = new Blob([res.data], { type: 'application/zip' }) |
| | | this.saveAs(blob, name) |
| | | } else { |
| | | Message.error('æ æçä¼è¯ï¼æè
ä¼è¯å·²è¿æï¼è¯·éæ°ç»å½ã'); |
| | | this.printErrMsg(res.data); |
| | | } |
| | | }) |
| | | }, |
| | | saveAs(text, name, opts) { |
| | | saveAs(text, name, opts); |
| | | }, |
| | | async printErrMsg(data) { |
| | | const resText = await data.text(); |
| | | const rspObj = JSON.parse(resText); |
| | | const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] |
| | | Message.error(errMsg); |
| | | } |
| | | } |
| | | |
| | |
| | | type: "warning",
|
| | | })
|
| | | },
|
| | | // æäº¤å
容
|
| | | prompt(content) {
|
| | | return MessageBox.prompt(content, "ç³»ç»æç¤º", {
|
| | | confirmButtonText: 'ç¡®å®',
|
| | | cancelButtonText: 'åæ¶',
|
| | | type: "warning",
|
| | | })
|
| | | },
|
| | | // æå¼é®ç½©å±
|
| | | loading(content) {
|
| | | loadingInstance = Loading.service({
|
| | |
| | | * redirect: noRedirect // å½è®¾ç½® noRedirect çæ¶å该路ç±å¨é¢å
å±å¯¼èªä¸ä¸å¯è¢«ç¹å» |
| | | * name:'router-name' // 设å®è·¯ç±çååï¼ä¸å®è¦å¡«åä¸ç¶ä½¿ç¨<keep-alive>æ¶ä¼åºç°åç§é®é¢ |
| | | * query: '{"id": 1, "name": "ry"}' // 访é®è·¯ç±çé»è®¤ä¼ éåæ° |
| | | * roles: ['admin', 'common'] // 访é®è·¯ç±çè§è²æé |
| | | * permissions: ['a:a:a', 'b:b:b'] // 访é®è·¯ç±çèåæé |
| | | * meta : { |
| | | noCache: true // å¦æè®¾ç½®ä¸ºtrueï¼åä¸ä¼è¢« <keep-alive> ç¼å(é»è®¤ false) |
| | | title: 'title' // 设置该路ç±å¨ä¾§è¾¹æ åé¢å
å±ä¸å±ç¤ºçåå |
| | |
| | | children: [ |
| | | { |
| | | path: '/redirect/:path(.*)', |
| | | component: (resolve) => require(['@/views/redirect'], resolve) |
| | | component: () => import('@/views/redirect') |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/login', |
| | | component: (resolve) => require(['@/views/login'], resolve), |
| | | component: () => import('@/views/login'), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/register', |
| | | component: (resolve) => require(['@/views/register'], resolve), |
| | | component: () => import('@/views/register'), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/404', |
| | | component: (resolve) => require(['@/views/error/404'], resolve), |
| | | component: () => import('@/views/error/404'), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/401', |
| | | component: (resolve) => require(['@/views/error/401'], resolve), |
| | | component: () => import('@/views/error/401'), |
| | | hidden: true |
| | | }, |
| | | { |
| | |
| | | children: [ |
| | | { |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/index'], resolve), |
| | | component: () => import('@/views/index'), |
| | | name: 'Index', |
| | | meta: { title: 'é¦é¡µ', icon: 'dashboard', affix: true } |
| | | } |
| | |
| | | children: [ |
| | | { |
| | | path: 'profile', |
| | | component: (resolve) => require(['@/views/system/user/profile/index'], resolve), |
| | | component: () => import('@/views/system/user/profile/index'), |
| | | name: 'Profile', |
| | | meta: { title: '个人ä¸å¿', icon: 'user' } |
| | | } |
| | | ] |
| | | }, |
| | | } |
| | | ] |
| | | |
| | | // å¨æè·¯ç±ï¼åºäºç¨æ·æé卿å»å è½½ |
| | | export const dynamicRoutes = [ |
| | | { |
| | | path: '/system/user-auth', |
| | | component: Layout, |
| | | hidden: true, |
| | | permissions: ['system:user:edit'], |
| | | children: [ |
| | | { |
| | | path: 'role/:userId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/user/authRole'], resolve), |
| | | component: () => import('@/views/system/user/authRole'), |
| | | name: 'AuthRole', |
| | | meta: { title: 'åé
è§è²', activeMenu: '/system/user' } |
| | | } |
| | |
| | | path: '/system/role-auth', |
| | | component: Layout, |
| | | hidden: true, |
| | | permissions: ['system:role:edit'], |
| | | children: [ |
| | | { |
| | | path: 'user/:roleId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/role/authUser'], resolve), |
| | | component: () => import('@/views/system/role/authUser'), |
| | | name: 'AuthUser', |
| | | meta: { title: 'åé
ç¨æ·', activeMenu: '/system/role' } |
| | | } |
| | |
| | | path: '/system/dict-data', |
| | | component: Layout, |
| | | hidden: true, |
| | | permissions: ['system:dict:list'], |
| | | children: [ |
| | | { |
| | | path: 'index/:dictId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/dict/data'], resolve), |
| | | component: () => import('@/views/system/dict/data'), |
| | | name: 'Data', |
| | | meta: { title: 'åå
¸æ°æ®', activeMenu: '/system/dict' } |
| | | } |
| | |
| | | path: '/system/oss-config', |
| | | component: Layout, |
| | | hidden: true, |
| | | permissions: ['system:oss:list'], |
| | | children: [ |
| | | { |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/system/oss/config'], resolve), |
| | | component: () => import('@/views/system/oss/config'), |
| | | name: 'OssConfig', |
| | | meta: { title: 'é
置管ç', activeMenu: '/system/oss'} |
| | | meta: { title: 'é
置管ç', activeMenu: '/system/oss' } |
| | | } |
| | | ] |
| | | }, |
| | |
| | | path: '/tool/gen-edit', |
| | | component: Layout, |
| | | hidden: true, |
| | | permissions: ['tool:gen:edit'], |
| | | children: [ |
| | | { |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/tool/gen/editTable'], resolve), |
| | | component: () => import('@/views/tool/gen/editTable'), |
| | | name: 'GenEdit', |
| | | meta: { title: 'ä¿®æ¹çæé
ç½®', activeMenu: '/tool/gen' } |
| | | } |
| | |
| | | import { constantRoutes } from '@/router' |
| | | import auth from '@/plugins/auth' |
| | | import router, { constantRoutes, dynamicRoutes } from '@/router' |
| | | import { getRouters } from '@/api/menu' |
| | | import Layout from '@/layout/index' |
| | | import ParentView from '@/components/ParentView' |
| | |
| | | const rdata = JSON.parse(JSON.stringify(res.data)) |
| | | const sidebarRoutes = filterAsyncRouter(sdata) |
| | | const rewriteRoutes = filterAsyncRouter(rdata, false, true) |
| | | const asyncRoutes = filterDynamicRoutes(dynamicRoutes); |
| | | rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) |
| | | router.addRoutes(asyncRoutes); |
| | | commit('SET_ROUTES', rewriteRoutes) |
| | | commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes)) |
| | | commit('SET_DEFAULT_ROUTES', sidebarRoutes) |
| | |
| | | return children |
| | | } |
| | | |
| | | // å¨æè·¯ç±éåï¼éªè¯æ¯å¦å
·å¤æé |
| | | export function filterDynamicRoutes(routes) { |
| | | const res = [] |
| | | routes.forEach(route => { |
| | | if (route.permissions) { |
| | | if (auth.hasPermiOr(route.permissions)) { |
| | | res.push(route) |
| | | } |
| | | } else if (route.roles) { |
| | | if (auth.hasRoleOr(route.roles)) { |
| | | res.push(route) |
| | | } |
| | | } |
| | | }) |
| | | return res |
| | | } |
| | | |
| | | export const loadView = (view) => { |
| | | if (process.env.NODE_ENV === 'development') { |
| | | return (resolve) => require([`@/views/${view}`], resolve) |
| | |
| | | const blob = new Blob([data]) |
| | | saveAs(blob, filename) |
| | | } else { |
| | | Message.error('æ æçä¼è¯ï¼æè
ä¼è¯å·²è¿æï¼è¯·éæ°ç»å½ã'); |
| | | const resText = await data.text(); |
| | | const rspObj = JSON.parse(resText); |
| | | const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] |
| | | Message.error(errMsg); |
| | | } |
| | | downloadLoadingInstance.close(); |
| | | }).catch((r) => { |
| | |
| | | }, |
| | | /** 强éæé®æä½ */ |
| | | handleForceLogout(row) { |
| | | this.$modal.confirm('æ¯å¦ç¡®è®¤å¼ºéå称为"' + row.userName + '"çæ°æ®é¡¹ï¼').then(function() { |
| | | this.$modal.confirm('æ¯å¦ç¡®è®¤å¼ºéå称为"' + row.userName + '"çç¨æ·ï¼').then(function() { |
| | | return forceLogout(row.tokenId); |
| | | }).then(() => { |
| | | this.getList(); |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" v-if="form.menuType != 'F'"> |
| | | <el-form-item label="èå徿 "> |
| | | <el-form-item label="èå徿 " prop="icon"> |
| | | <el-popover |
| | | placement="bottom-start" |
| | | width="460" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8" :offset="2"> |
| | | <el-form-item label="ç»å½è´¦å·" prop="phonenumber"> |
| | | <el-form-item label="ç»å½è´¦å·" prop="userName"> |
| | | <el-input v-model="form.userName" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | cancelButtonText: "åæ¶", |
| | | closeOnClickModal: false, |
| | | inputPattern: /^.{5,20}$/, |
| | | inputErrorMessage: "ç¨æ·å¯ç é¿åº¦å¿
é¡»ä»äº 5 å 20 ä¹é´", |
| | | inputErrorMessage: "ç¨æ·å¯ç é¿åº¦å¿
é¡»ä»äº 5 å 20 ä¹é´" |
| | | }).then(({ value }) => { |
| | | resetUserPwd(row.userId, value).then(response => { |
| | | this.$modal.msgSuccess("ä¿®æ¹æåï¼æ°å¯ç æ¯ï¼" + value); |
| | |
| | | this.upload.open = false; |
| | | this.upload.isUploading = false; |
| | | this.$refs.upload.clearFiles(); |
| | | this.$alert(response.msg, "导å
¥ç»æ", { dangerouslyUseHTMLString: true }); |
| | | this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导å
¥ç»æ", { dangerouslyUseHTMLString: true }); |
| | | this.getList(); |
| | | }, |
| | | // æäº¤ä¸ä¼ æä»¶ |
| | |
| | | <el-input placeholder="请è¾å
¥" v-model="info.tableComment" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="å®ä½ç±»åç§°" prop="className"> |
| | | <el-input placeholder="请è¾å
¥" v-model="info.className" /> |
| | |
| | | </el-row> |
| | | </el-form> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "BasicInfoForm", |
| | | props: { |
| | | info: { |
| | | type: Object, |
| | |
| | | </el-form> |
| | | </el-card> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getGenTable, updateGenTable } from "@/api/tool/gen"; |
| | | import { optionselect as getDictOptionselect } from "@/api/system/dict/type"; |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item prop="packageName"> |
| | | <span slot="label"> |
| | |
| | | </el-row> |
| | | </el-form> |
| | | </template> |
| | | |
| | | <script> |
| | | import Treeselect from "@riophae/vue-treeselect"; |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| | | |
| | | export default { |
| | | name: "BasicInfoForm", |
| | | components: { Treeselect }, |
| | | props: { |
| | | info: { |
| | |
| | | :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" |
| | | :key="key" |
| | | > |
| | | <pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre> |
| | | <el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="value" v-clipboard:success="clipboardSuccess" style="float:right">å¤å¶</el-link> |
| | | <pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | </el-dialog> |
| | |
| | | const result = hljs.highlight(language, code || "", true); |
| | | return result.value || ' '; |
| | | }, |
| | | /** å¤å¶ä»£ç æå */ |
| | | clipboardSuccess(){ |
| | | this.$modal.msgSuccess("å¤å¶æå"); |
| | | }, |
| | | // å¤éæ¡é䏿°æ® |
| | | handleSelectionChange(selection) { |
| | | this.ids = selection.map(item => item.tableId); |
| | |
| | | return path.join(__dirname, dir) |
| | | } |
| | | |
| | | const CompressionPlugin = require('compression-webpack-plugin') |
| | | |
| | | const name = process.env.VUE_APP_TITLE || 'RuoYi-Vue-Plusåå°ç®¡çç³»ç»' // ç½é¡µæ é¢ |
| | | |
| | | const port = process.env.port || process.env.npm_config_port || 80 // ç«¯å£ |
| | |
| | | }, |
| | | disableHostCheck: true |
| | | }, |
| | | css: { |
| | | loaderOptions: { |
| | | sass: { |
| | | sassOptions: { outputStyle: "expanded" } |
| | | } |
| | | } |
| | | }, |
| | | configureWebpack: { |
| | | name: name, |
| | | resolve: { |
| | | alias: { |
| | | '@': resolve('src') |
| | | } |
| | | } |
| | | }, |
| | | plugins: [ |
| | | // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使ç¨gzipè§£åç¼©éææä»¶ |
| | | new CompressionPlugin({ |
| | | test: /\.(js|css|html)?$/i, // å缩æä»¶æ ¼å¼ |
| | | filename: '[path].gz[query]', // å缩åçæä»¶å |
| | | algorithm: 'gzip', // 使ç¨gzipå缩 |
| | | minRatio: 0.8 // å缩çå°äº1æä¼å缩 |
| | | }) |
| | | ], |
| | | }, |
| | | chainWebpack(config) { |
| | | config.plugins.delete('preload') // TODO: need test |
| | |
| | | #ssl_prefer_server_ciphers on; |
| | | # httpsé
ç½®åè end |
| | | |
| | | # æ¼ç¤ºç¯å¢é
ç½® æ¦æªé¤ GET POST ä¹å¤çææè¯·æ± |
| | | # if ($request_method !~* GET|POST) { |
| | | # rewrite ^/(.*)$ /403; |
| | | # } |
| | | |
| | | # location = /403 { |
| | | # default_type application/json; |
| | | # return 200 '{"msg":"æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½","code":500}'; |
| | | # } |
| | | |
| | | location / { |
| | | root /usr/share/nginx/html; |
| | | try_files $uri $uri/ /index.html; |
| | |
| | | proxy_pass http://server/; |
| | | } |
| | | |
| | | # https 伿¦æªå
龿æç http è¯·æ± é æåè½æ æ³ä½¿ç¨ |
| | | # è§£å³æ¹æ¡1 å° admin æå¡ ä¹é
ç½®æ https |
| | | # è§£å³æ¹æ¡2 å°èåé
置为å¤é¾è®¿é® èµ°ç¬ç«é¡µé¢ http è®¿é® |
| | | location /admin/ { |
| | | proxy_set_header Host $http_host; |
| | | proxy_set_header X-Real-IP $remote_addr; |
| | |
| | | proxy_pass http://monitor-admin/admin/; |
| | | } |
| | | |
| | | # https 伿¦æªå
龿æç http è¯·æ± é æåè½æ æ³ä½¿ç¨ |
| | | # è§£å³æ¹æ¡1 å° xxljob æå¡ ä¹é
ç½®æ https |
| | | # è§£å³æ¹æ¡2 å°èåé
置为å¤é¾è®¿é® èµ°ç¬ç«é¡µé¢ http è®¿é® |
| | | location /xxl-job-admin/ { |
| | | proxy_set_header Host $http_host; |
| | | proxy_set_header X-Real-IP $remote_addr; |
| | |
| | | # redis å¯ç |
| | | # requirepass ruoyi123 |
| | | |
| | | # key çå¬å¨é
ç½® |
| | | # notify-keyspace-events Ex |
| | | |
| | | # é
ç½®æä¹
åæä»¶åå¨è·¯å¾ |
| | | dir /redis/data |
| | | # é
ç½®rdb |