Jelajahi Sumber

更新 代码生成器
更新 租户代码
更新 租户套餐代码

18339543638 2 tahun lalu
induk
melakukan
8ddf3bfb4e
17 mengubah file dengan 212 tambahan dan 166 penghapusan
  1. 1 1
      tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/basic/controller/GenBasicController.java
  2. 1 1
      tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/basic/service/GenBasicService.java
  3. 33 27
      tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/basic/service/impl/GenBasicServiceImpl.java
  4. 1 1
      tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/config/entity/GenConfig.java
  5. 2 2
      tr-modules/tr-module-gen/src/main/resources/backend/Controller.java.btl
  6. 14 0
      tr-modules/tr-module-gen/src/main/resources/sqlend/Mysql.sql.btl
  7. 14 0
      tr-modules/tr-module-gen/src/main/resources/sqlend/Oracle.sql.btl
  8. 22 3
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/dict/service/impl/SysDictServiceImpl.java
  9. 44 47
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/controller/SysTenantController.java
  10. 49 64
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/controller/SysTenantPackageController.java
  11. 1 1
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/ISysTenantPackageService.java
  12. 1 1
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/ISysTenantService.java
  13. 1 1
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantPackageServiceImpl.java
  14. 1 1
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantServiceImpl.java
  15. 24 15
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/provider/SysMenuApiProvider.java
  16. 1 0
      tr-plugins/tr-spring-boot-starter-plugin-web/src/main/java/cn/tr/plugin/web/config/TrWebMvcConfig.java
  17. 2 1
      tr-test/src/main/resources/application.yml

+ 1 - 1
tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/basic/controller/GenBasicController.java

@@ -193,7 +193,7 @@ public class GenBasicController extends BaseController {
     @ApiOperation("预览代码生成")
     @GetMapping(value = "/gen/basic/previewGen")
     public CommonResult<GenBasicPreviewResult> previewGen(@Valid GenBasicIdParam genBasicIdParam) {
-        return CommonResult.success(genBasicService.previewGen(genBasicIdParam));
+        return CommonResult.success(genBasicService.previewGen(genBasicIdParam,null));
     }
 }
 

+ 1 - 1
tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/basic/service/GenBasicService.java

@@ -116,5 +116,5 @@ public interface GenBasicService extends IService<GenBasic> {
      * @author xuyuxiang
      * @date 2022/10/28 17:08
      **/
-    GenBasicPreviewResult previewGen(GenBasicIdParam genBasicIdParam);
+    GenBasicPreviewResult previewGen(GenBasicIdParam genBasicIdParam, String componentPath);
 }

+ 33 - 27
tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/basic/service/impl/GenBasicServiceImpl.java

@@ -210,7 +210,7 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
                     .map(GenBasic::getDbTable)
                     .collect(Collectors.toSet());
 
-           ;
+            ;
             conn = DriverManager.getConnection(Objects.requireNonNull(environment.getProperty(DB_URL_KEY)),
                     Objects.requireNonNull(environment.getProperty(DB_USERNAME_KEY)),
                     Objects.requireNonNull(environment.getProperty(DB_PASSWORD_KEY)));
@@ -295,13 +295,14 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void execGenZip(GenBasicIdParam genBasicIdParam, HttpServletResponse response) throws IOException {
-        File tempFolder = this.genTempFolder(genBasicIdParam, response, true);
+        GenBasic genBasic = this.queryEntity(genBasicIdParam.getId());
+        Pair<String, String> idAndComponentPath = sysMenuApi.addForGenMenu(genBasic.getMenuPid(),genBasic.getBusName(), genBasic.getFrontModuleName(), genBasic.getBackendModuleName(),genBasic.getBackendModuleName()+":"+genBasic.getBusName()+":", genBasic.getFunctionName());
+
+        File tempFolder = this.genTempFolder(genBasicIdParam,idAndComponentPath.getValue(), response, true);
         if(tempFolder == null) {
             CommonResponseUtil.renderError(response, "代码生成基础不存在,id值为:" + genBasicIdParam.getId());
             return;
         }
-        GenBasic genBasic = this.queryEntity(genBasicIdParam.getId());
-        Pair<String, String> idAndComponentId = sysMenuApi.addForGenMenu(genBasic.getMenuPid(),genBasic.getBusName(), genBasic.getFrontModuleName(), genBasic.getBackendModuleName(),genBasic.getBackendModuleName()+":"+genBasic.getBusName()+":", genBasic.getFunctionName());
         // 压缩
         File zip = ZipUtil.zip(tempFolder);
         // 压缩完毕删除临时目录
@@ -313,27 +314,26 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void execGenPro(GenBasicIdParam genBasicIdParam, HttpServletResponse response) throws IOException {
-        File tempFolder = this.genTempFolder(genBasicIdParam, response, false);
-        // 定义前端生成的目录
-        String genProjectFrontendPath = System.getProperty("user.dir") + File.separator + GEN_PROJECT_FRONT_PLUGIN_KEY + File.separator + "src";
-
-        if(!FileUtil.exist(genProjectFrontendPath)) {
-            throw new  ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("前端代码生成位置:{%s}不存在,请检查位置", genProjectFrontendPath));
-        }
-
-        // 定义后端生成的目录
-        String genProjectBackendPath = System.getProperty("user.dir") + File.separator + GEN_PROJECT_PLUGIN_BIZ_KEY + File.separator + "src" +
-                File.separator + "main" + File.separator + "java";
-
-        if(!FileUtil.exist(genProjectBackendPath)) {
-            throw new  ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("后端代码生成位置:{%s}不存在,请检查位置", genProjectBackendPath));
-        }
         try {
             GenBasic genBasic = this.queryEntity(genBasicIdParam.getId());
-
             // 生成菜单
             Pair<String, String> idAndComponentId = sysMenuApi.addForGenMenu(genBasic.getMenuPid(), genBasic.getBusName(),genBasic.getFrontModuleName(), genBasic.getBackendModuleName(), genBasic.getFunctionName(),genBasic.getBackendModuleName()+":"+genBasic.getBusName()+":");
 
+            File tempFolder = this.genTempFolder(genBasicIdParam, idAndComponentId.getValue(),response, false);
+            // 定义前端生成的目录
+            String genProjectFrontendPath = System.getProperty("user.dir") + File.separator + GEN_PROJECT_FRONT_PLUGIN_KEY + File.separator + "src";
+
+            if(!FileUtil.exist(genProjectFrontendPath)) {
+                throw new  ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("前端代码生成位置:{%s}不存在,请检查位置", genProjectFrontendPath));
+            }
+
+            // 定义后端生成的目录
+            String genProjectBackendPath = System.getProperty("user.dir") + File.separator + GEN_PROJECT_PLUGIN_BIZ_KEY + File.separator + "src" +
+                    File.separator + "main" + File.separator + "java";
+
+            if(!FileUtil.exist(genProjectBackendPath)) {
+                throw new  ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("后端代码生成位置:{%s}不存在,请检查位置", genProjectBackendPath));
+            }
             //前端代码移动到前端
             FileUtil.moveContent(FileUtil.file(tempFolder + File.separator + "frontend"), FileUtil.file(genProjectFrontendPath), true);
 
@@ -354,7 +354,7 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
      * @author xuyuxiang yubaoshan
      * @date 2022/10/28 21:36
      */
-    private File genTempFolder(GenBasicIdParam genBasicIdParam, HttpServletResponse response, boolean isZip) throws IOException {
+    private File genTempFolder(GenBasicIdParam genBasicIdParam,String componentPath, HttpServletResponse response, boolean isZip) throws IOException {
         GenBasic genBasic = this.getById(genBasicIdParam.getId());
         if(ObjectUtil.isEmpty(genBasic)) {
             // 如果是压缩包下载应该使用CommonResponseUtil渲染异常
@@ -365,7 +365,7 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
                 throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("代码生成基础不存在,id值为:{%s}", genBasicIdParam.getId()));
             }
         }
-        GenBasicPreviewResult genBasicPreviewResult = this.previewGen(genBasicIdParam);
+        GenBasicPreviewResult genBasicPreviewResult = this.previewGen(genBasicIdParam,componentPath);
         // 先删除压缩包
         FileUtil.del(FileUtil.getTmpDirPath() + File.separator + genBasic.getFunctionName() + ".zip");
         // 生成临时目录
@@ -377,7 +377,7 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
         // 生成前端代码到临时目录
         genBasicPreviewResult.getGenBasicCodeFrontendResultList().forEach(genBasicCodeResult ->
                 FileUtil.writeUtf8String(genBasicCodeResult.getCodeFileContent(), FileUtil.file(tempFolder + File.separator
-                        + "frontend" + File.separator + File.separator+genBasicCodeResult.getCodeFileWithPathName())));
+                        + "frontend" + File.separator +genBasicCodeResult.getCodeFileWithPathName())));
         // 生成后端代码到临时目录
         genBasicPreviewResult.getGenBasicCodeBackendResultList().forEach(genBasicCodeResult ->
                 FileUtil.writeUtf8String(genBasicCodeResult.getCodeFileContent(), FileUtil.file(tempFolder + File.separator
@@ -386,7 +386,7 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
     }
 
     @Override
-    public GenBasicPreviewResult previewGen(GenBasicIdParam genBasicIdParam) {
+    public GenBasicPreviewResult previewGen(GenBasicIdParam genBasicIdParam, String componentPath) {
         GenBasic genBasic = this.queryEntity(genBasicIdParam.getId());
         JSONObject bindingJsonObject = this.getBindingJsonObject(genBasic);
         GenBasicPreviewResult genBasicPreviewResult = new GenBasicPreviewResult();
@@ -429,7 +429,11 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
                     genBasicCodeFrontResult.setCodeFileWithPathName(genFrontBasicPath + File.separator +fileTemplatePath +File.separator+genBasic.getFrontModuleName()+ File.separator + resultName);
                 } else {
                     genBasicCodeFrontResult.setCodeFileName(resultName);
-                    genBasicCodeFrontResult.setCodeFileWithPathName(genFrontBasicPath + File.separator + fileTemplatePath+File.separator+genBasic.getFrontModuleName() + File.separator + genBasic.getBusName() + File.separator + resultName);
+                    if (StrUtil.isNotEmpty(componentPath)) {
+                        genBasicCodeFrontResult.setCodeFileWithPathName(genFrontBasicPath + File.separator + fileTemplatePath+File.separator+componentPath + File.separator + resultName);
+                    }else {
+                        genBasicCodeFrontResult.setCodeFileWithPathName(genFrontBasicPath + File.separator + fileTemplatePath+File.separator+genBasic.getFrontModuleName() + File.separator + genBasic.getBusName() + File.separator + resultName);
+                    }
                 }
                 genBasicCodeFrontResult.setCodeFileContent(templateFront.render());
                 genBasicCodeFrontendResultList.add(genBasicCodeFrontResult);
@@ -634,11 +638,12 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
     private void addTableColumns(GenBasic genBasic){
         if(StrUtil.isNotEmpty(genBasic.getId())){
             genConfigMapper.delete(new LambdaQueryWrapper<GenConfig>()
-            .eq(GenConfig::getBasicId,genBasic.getId()));
+                    .eq(GenConfig::getBasicId,genBasic.getId()));
         }
         GenBasicTableColumnParam tableColumnParam = new GenBasicTableColumnParam();
         tableColumnParam.setTableName(genBasic.getDbTable());
         List<GenBasicTableColumnResult> resultList = this.tableColumns(tableColumnParam);
+        List<GenConfig> configs = new ArrayList<>();
         for (int i = 0; i < resultList.size(); i++) {
             GenBasicTableColumnResult item = resultList.get(i);
             GenConfigAddParam addParam = new GenConfigAddParam();
@@ -675,7 +680,8 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
             addParam.setQueryWhether(GenYesNoEnum.N.getValue());
             addParam.setSortCode(i);
             GenConfig genConfig = BeanUtil.toBean(addParam, GenConfig.class);
-            genConfigService.save(genConfig);
+            configs.add(genConfig);
         }
+        genConfigService.saveBatch(configs);
     }
 }

+ 1 - 1
tr-modules/tr-module-gen/src/main/java/cn/tr/module/gen/modular/config/entity/GenConfig.java

@@ -93,5 +93,5 @@ public class GenConfig extends BasePO {
 
     /** 排序 */
     @ApiModelProperty(value = "排序", position = 16)
-    private String sortCode;
+    private Integer sortCode;
 }

+ 2 - 2
tr-modules/tr-module-gen/src/main/resources/backend/Controller.java.btl

@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 import ${packageName}.${backendModuleName}.${busName}.dto.${className}DTO;
-import ${packageName}.${backendModuleName}.${busName}.service.${className}Service;
+import ${packageName}.${backendModuleName}.${busName}.service.I${className}Service;
 import ${packageName}.${backendModuleName}.${busName}.dto.${className}QueryDTO;
 import java.util.*;
 import cn.tr.plugin.mybatis.base.BaseController;
@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.*;
 @AllArgsConstructor
 public class ${className}Controller extends BaseController{
 
-    private final ${className}Service ${classNameFirstLower}Service;
+    private final I${className}Service ${classNameFirstLower}Service;
 
     @ApiOperationSupport(author = "${authorName}",order = 1)
     @ApiOperation(value="根据条件查询${functionName}",notes = "权限: ${backendModuleName}:${busName}:query")

+ 14 - 0
tr-modules/tr-module-gen/src/main/resources/sqlend/Mysql.sql.btl

@@ -0,0 +1,14 @@
+/*
+ Source Server Type: MySQL
+ Date: ${genTime}
+*/
+
+INSERT INTO `SYS_RESOURCE` VALUES ('${menuId}', '${parentId}', '${functionName}管理', '${busName}', '${menuCode}', 'MENU', '${moduleId}', 'MENU', '${menuPath}', '${menuComponent}', NULL, NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO `SYS_RESOURCE` VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', NULL, '${classNameFirstLower}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO `SYS_RESOURCE` VALUES ('${batchDeleteButtonId}', '${menuId}', '批量删除${functionName}', NULL, '${classNameFirstLower}BatchDelete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO `SYS_RESOURCE` VALUES ('${editButtonId}', '${menuId}', '编辑${functionName}', NULL, '${classNameFirstLower}Edit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, 3, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO `SYS_RESOURCE` VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', NULL, '${classNameFirstLower}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, 4, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);

+ 14 - 0
tr-modules/tr-module-gen/src/main/resources/sqlend/Oracle.sql.btl

@@ -0,0 +1,14 @@
+/*
+ Source Server Type: Oracle
+ Date: ${genTime}
+*/
+
+INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${menuId}', '${parentId}', '${functionName}管理', '${busName}', '${menuCode}', 'MENU', '${moduleId}', 'MENU', '${menuPath}', '${menuComponent}', NULL, NULL, '99', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', NULL, '${classNameFirstLower}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${batchDeleteButtonId}', '${menuId}', '批量删除${functionName}', NULL, '${classNameFirstLower}BatchDelete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, '2', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${editButtonId}', '${menuId}', '编辑${functionName}', NULL, '${classNameFirstLower}Edit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, '3', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
+
+INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', NULL, '${classNameFirstLower}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, '4', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);

+ 22 - 3
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/dict/service/impl/SysDictServiceImpl.java

@@ -10,12 +10,15 @@ import cn.tr.module.sys.dict.po.SysDictItemPO;
 import cn.tr.module.sys.dict.po.SysDictPO;
 import cn.tr.module.sys.dict.repository.SysDictItemRepository;
 import cn.tr.module.sys.dict.repository.SysDictRepository;
+import cn.tr.module.sys.dict.service.ISysDictItemService;
 import cn.tr.module.sys.dict.service.ISysDictService;
 import cn.tr.module.sys.mapper.dict.DictMapper;
 import cn.tr.plugin.dict.config.cache.DictManager;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -30,11 +33,16 @@ import java.util.List;
  * @Date: 2023年03月24日
  */
 @Slf4j
-@AllArgsConstructor
 @Service
 public class SysDictServiceImpl implements ISysDictService {
-    private final SysDictRepository dictRepository;
-    private final SysDictItemRepository dictItemRepository;
+    @Autowired
+    private SysDictRepository dictRepository;
+    @Autowired
+    private SysDictItemRepository dictItemRepository;
+    @Autowired
+    @Lazy
+    private ISysDictItemService dictItemService;
+
     @Override
     public List<SysDictDTO> selectDictDataList(SysDictQueryDTO query) {
         return DictMapper.INSTANCE.toDictDtoList(dictRepository.selectList(
@@ -81,15 +89,18 @@ public class SysDictServiceImpl implements ISysDictService {
         if(dictByCode!=null){
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("字典编码{%s}不能重复",source.getDictCode()));
         }
+        refreshCache(dict.getDictCode());
         return dictRepository.insert(dict)!=0;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int deleteDictByIds(Collection<String> ids) {
+        List<SysDictPO> dicts = dictRepository.selectBatchIds(ids);
         int result = dictRepository.deleteBatchIds(ids);
         dictItemRepository.delete(new LambdaQueryWrapper<SysDictItemPO>()
         .in(SysDictItemPO::getDictId,ids));
+        dicts.forEach(dict->refreshCache(dict.getDictCode()));
         return result;
     }
 
@@ -100,6 +111,14 @@ public class SysDictServiceImpl implements ISysDictService {
         if(dictByCode!=null&&!StrUtil.equals(source.getId(),dictByCode.getId())){
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("字典编码{%s}不能重复",source.getDictCode()));
         }
+        SysDictPO oldDict = dictRepository.selectById(source);
+        if(oldDict!=null){
+            refreshCache(oldDict.getDictCode());
+        }
         return dictRepository.updateById(dict)!=0;
     }
+
+    private void refreshCache(String code){
+        dictItemService.delCache(code);
+    }
 }

+ 44 - 47
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/controller/SysTenantController.java

@@ -1,80 +1,77 @@
 package cn.tr.module.sys.tenant.controller;
 
-import cn.dev33.satoken.annotation.SaCheckPermission;
-import cn.tr.core.pojo.CommonResult;
-import cn.tr.core.pojo.TableDataInfo;
-import cn.tr.core.validation.Insert;
-import cn.tr.core.validation.Update;
 import cn.tr.module.sys.tenant.dto.SysTenantAddDTO;
 import cn.tr.module.sys.tenant.dto.SysTenantCommonDTO;
-import cn.tr.module.sys.tenant.dto.SysTenantQueryDTO;
-import cn.tr.module.sys.tenant.service.ISysTenantService;
-import cn.tr.plugin.mybatis.base.BaseController;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.tr.core.validation.Insert;
+import cn.tr.core.validation.Update;
+import cn.tr.core.pojo.CommonResult;
+import lombok.AllArgsConstructor;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import lombok.AllArgsConstructor;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import cn.tr.module.sys.tenant.service.ISysTenantService;
+import cn.tr.module.sys.tenant.dto.SysTenantQueryDTO;
+import java.util.*;
+import cn.tr.plugin.mybatis.base.BaseController;
 import org.springframework.web.bind.annotation.*;
-
-import java.util.Collection;
-
 /**
- * @ClassName : SysTenantController
- * @Description :
- * @Author : LF
- * @Date: 2023年03月24日
+ * 租户列表控制器
+ *
+ * @author lf
+ * @date  2023/04/15 15:27
  */
+@Api(tags = "租户列表控制器")
 @RestController
 @RequestMapping("/sys/tenant")
-@Api(tags = "租户")
 @AllArgsConstructor
-public class SysTenantController extends BaseController {
-    private final ISysTenantService tenantService;
+public class SysTenantController extends BaseController{
 
+    private final ISysTenantService sysTenantService;
 
+    @ApiOperationSupport(author = "lf",order = 1)
+    @ApiOperation(value="根据条件查询租户列表",notes = "权限: sys:tenant:query")
     @PostMapping("/query/page")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "根据条件查询租户",notes = "权限: sys:tenant:query")
     @SaCheckPermission("sys:tenant:query")
-    public TableDataInfo<SysTenantCommonDTO> selectList(@RequestBody SysTenantQueryDTO query){
+    public CommonResult<List<SysTenantCommonDTO>> selectList(@RequestBody SysTenantQueryDTO query) {
         startPage();
-        return getDataTable(tenantService.selectSysTenantList(query));
+        return CommonResult.success(sysTenantService.selectSysTenantList(query));
     }
 
+    @ApiOperationSupport(author = "lf",order = 2)
+    @ApiOperation(value = "根据id查询租户列表",notes = "权限: sys:tenant:query")
     @GetMapping("/detail/{id}")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "根据id查询租户",notes = "权限: sys:tenant:query")
     @SaCheckPermission("sys:tenant:query")
     public CommonResult<SysTenantCommonDTO> findById(@PathVariable("id") String id){
-        return CommonResult.success(tenantService.selectSysTenantById(id));
-    }
-
-    @PostMapping("/edit")
-    @ApiOperationSupport(author = "lf")
-    @SaCheckPermission("sys:tenant:edit")
-    @ApiOperation(value = "根据id更新租户",notes = "权限: sys:tenant:edit")
-    public CommonResult<Boolean> edit(@RequestBody@Validated(Update.class) SysTenantCommonDTO source){
-        return CommonResult.success(tenantService.updateSysTenantById(source));
+        return CommonResult.success(sysTenantService.selectSysTenantById(id));
     }
 
+    @ApiOperationSupport(author = "lf",order = 3)
+    @ApiOperation(value="添加租户列表",notes = "权限: sys:tenant:add")
     @PostMapping("/add")
-    @ApiOperationSupport(author = "lf")
     @SaCheckPermission("sys:tenant:add")
-    @ApiOperation(value = "新增租户",notes = "权限: sys:tenant:add")
-    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) SysTenantAddDTO source){
-        return CommonResult.success(tenantService.insertSysTenant(source));
+    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) SysTenantAddDTO source) {
+        return CommonResult.success(sysTenantService.insertSysTenant(source));
     }
 
-    @PostMapping("/deleteByIds")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "删除租户",notes = "权限: sys:tenant:del")
-    @SaCheckPermission("sys:tenant:del")
-    public CommonResult<Integer> deleteByIds(@RequestBody Collection<String> ids){
-        return CommonResult.success(tenantService.deleteSysTenantByIds(ids));
+    @ApiOperationSupport(author = "lf",order = 4)
+    @ApiOperation(value="通过主键id编辑租户列表",notes = "权限: sys:tenant:edit")
+    @PostMapping("/edit")
+    @SaCheckPermission("sys:tenant:edit")
+    public CommonResult<Boolean> edit(@RequestBody@Validated(Update.class) SysTenantCommonDTO source) {
+        return CommonResult.success(sysTenantService.updateSysTenantById(source));
     }
-    
-
-    //todo 导出
 
+    @ApiOperationSupport(author = "lf",order = 5)
+    @ApiOperation(value="删除租户列表",notes = "权限: sys:tenant:remove")
+    @PostMapping("/removeByIds")
+    @SaCheckPermission("sys:tenant:remove")
+    public CommonResult<Integer> delete(@RequestBody Collection<String> ids) {
+        return CommonResult.success(sysTenantService.removeSysTenantByIds(ids));
+    }
 }

+ 49 - 64
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/controller/SysTenantPackageController.java

@@ -1,91 +1,76 @@
-package cn.tr.module.sys.tenant.controller;
+package cn.tr.module.tenant.tenantPackage.controller;
 
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import cn.dev33.satoken.annotation.SaCheckPermission;
-import cn.tr.core.pojo.CommonResult;
-import cn.tr.core.pojo.TableDataInfo;
 import cn.tr.core.validation.Insert;
 import cn.tr.core.validation.Update;
-import cn.tr.module.sys.tenant.dto.*;
-import cn.tr.module.sys.tenant.enums.PackageEnum;
-import cn.tr.module.sys.tenant.service.ISysTenantPackageMenuService;
-import cn.tr.module.sys.tenant.service.ISysTenantPackageService;
-import cn.tr.plugin.mybatis.base.BaseController;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import cn.tr.core.pojo.CommonResult;
+import lombok.AllArgsConstructor;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import lombok.AllArgsConstructor;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import cn.tr.module.sys.tenant.dto.SysTenantPackageDTO;
+import cn.tr.module.sys.tenant.service.ISysTenantPackageService;
+import cn.tr.module.sys.tenant.dto.SysTenantPackageQueryDTO;
+import java.util.*;
+import cn.tr.plugin.mybatis.base.BaseController;
 import org.springframework.web.bind.annotation.*;
-
-import java.util.Collection;
-import java.util.List;
-
 /**
- * @ClassName : SysTenantController
- * @Description :
- * @Author : LF
- * @Date: 2023年03月24日
+ * 租户套餐控制器
+ *
+ * @author lf
+ * @date  2023/04/15 15:28
  */
+@Api(tags = "租户套餐控制器")
 @RestController
-@RequestMapping("/sys/tenantPackage")
-@Api(tags = "租户套餐")
+@RequestMapping("/tenant/tenantPackage")
 @AllArgsConstructor
-public class SysTenantPackageController extends BaseController {
-    private final ISysTenantPackageService tenantPackageService;
-    private final ISysTenantPackageMenuService tenantPackageMenuService;
-    @PostMapping("/assign")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "为套餐分配菜单",notes = "权限: sys:tenantPackage:assign")
-    @SaCheckPermission("sys:tenantPackage:assign")
-    public CommonResult<Boolean> selectList(@RequestBody@Validated List<SysTenantPackageMenuDTO> source){
-        tenantPackageMenuService.assignPackageMenu(source);
-        return CommonResult.success(true);
-    }
+public class SysTenantPackageController extends BaseController{
 
+    private final ISysTenantPackageService sysTenantPackageService;
+
+    @ApiOperationSupport(author = "lf",order = 1)
+    @ApiOperation(value="根据条件查询租户套餐",notes = "权限: tenant:tenantPackage:query")
     @PostMapping("/query/page")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "根据条件查询租户套餐",notes = "权限: sys:tenantPackage:query")
-    @SaCheckPermission("sys:tenantPackage:query")
-    public TableDataInfo<SysTenantPackageDTO> selectList(@RequestBody SysTenantPackageQueryDTO query){
+    @SaCheckPermission("tenant:tenantPackage:query")
+    public CommonResult<List<SysTenantPackageDTO>> selectList(@RequestBody SysTenantPackageQueryDTO query) {
         startPage();
-        return getDataTable(tenantPackageService.selectSysTenantPackageList(query));
+        return CommonResult.success(sysTenantPackageService.selectSysTenantPackageList(query));
     }
 
+    @ApiOperationSupport(author = "lf",order = 2)
+    @ApiOperation(value = "根据id查询租户套餐",notes = "权限: tenant:tenantPackage:query")
     @GetMapping("/detail/{id}")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "根据id查询租户套餐",notes = "权限: sys:tenantPackage:query")
-    @SaCheckPermission("sys:tenantPackage:query")
+    @SaCheckPermission("tenant:tenantPackage:query")
     public CommonResult<SysTenantPackageDTO> findById(@PathVariable("id") String id){
-        return CommonResult.success(tenantPackageService.selectSysTenantPackageById(id));
-    }
-
-    @PostMapping("/edit")
-    @ApiOperationSupport(author = "lf")
-    @SaCheckPermission("sys:tenantPackage:edit")
-    @ApiOperation(value = "根据id更新租户套餐",notes = "权限: sys:tenantPackage:edit")
-    public CommonResult<Boolean> edit(@RequestBody@Validated(Update.class) SysTenantPackageDTO source){
-        source.setType(PackageEnum.custom.name());
-        return CommonResult.success(tenantPackageService.updateSysTenantPackageById(source));
+        return CommonResult.success(sysTenantPackageService.selectSysTenantPackageById(id));
     }
 
+    @ApiOperationSupport(author = "lf",order = 3)
+    @ApiOperation(value="添加租户套餐",notes = "权限: tenant:tenantPackage:add")
     @PostMapping("/add")
-    @ApiOperationSupport(author = "lf")
-    @SaCheckPermission("sys:tenantPackage:add")
-    @ApiOperation(value = "新增租户套餐",notes = "权限: sys:tenantPackage:add")
-    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) SysTenantPackageDTO source){
-        source.setType(PackageEnum.custom.name());
-        return CommonResult.success(tenantPackageService.insertSysTenantPackage(source));
+    @SaCheckPermission("tenant:tenantPackage:add")
+    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) SysTenantPackageDTO source) {
+        return CommonResult.success(sysTenantPackageService.insertSysTenantPackage(source));
     }
 
-    @PostMapping("/deleteByIds")
-    @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "删除租户套餐",notes = "权限: sys:tenantPackage:del")
-    @SaCheckPermission("sys:tenantPackage:del")
-    public CommonResult<Integer> deleteByIds(@RequestBody Collection<String> ids){
-        return CommonResult.success(tenantPackageService.deleteSysTenantPackageByIds(ids));
+    @ApiOperationSupport(author = "lf",order = 4)
+    @ApiOperation(value="通过主键id编辑租户套餐",notes = "权限: tenant:tenantPackage:edit")
+    @PostMapping("/edit")
+    @SaCheckPermission("tenant:tenantPackage:edit")
+    public CommonResult<Boolean> edit(@RequestBody@Validated(Update.class) SysTenantPackageDTO source) {
+        return CommonResult.success(sysTenantPackageService.updateSysTenantPackageById(source));
     }
-    
-
-    //todo 导出
 
+    @ApiOperationSupport(author = "lf",order = 5)
+    @ApiOperation(value="删除租户套餐",notes = "权限: tenant:tenantPackage:remove")
+    @PostMapping("/removeByIds")
+    @SaCheckPermission("tenant:tenantPackage:remove")
+    public CommonResult<Integer> delete(@RequestBody Collection<String> ids) {
+        return CommonResult.success(sysTenantPackageService.removeSysTenantPackageByIds(ids));
+    }
 }

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/ISysTenantPackageService.java

@@ -47,7 +47,7 @@ public interface ISysTenantPackageService {
      * @param ids 租户套餐id
      * @return 删除数量
      */
-    int deleteSysTenantPackageByIds(Collection<String> ids);
+    int removeSysTenantPackageByIds(Collection<String> ids);
 
     Collection<SysTenantPackageDTO> findAllSysPackages();
 }

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/ISysTenantService.java

@@ -54,7 +54,7 @@ public interface ISysTenantService {
      * @param ids 租户id
      * @return 删除数量
      */
-    int deleteSysTenantByIds(Collection<String> ids);
+    int removeSysTenantByIds(Collection<String> ids);
     /**
      * 获取当前租户的菜单id
      * @return

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantPackageServiceImpl.java

@@ -76,7 +76,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
     }
 
     @Override
-    public int deleteSysTenantPackageByIds(Collection<String> ids) {
+    public int removeSysTenantPackageByIds(Collection<String> ids) {
         validatePackageSource(ids);
         List<SysTenantPO> tenants = tenantRepository.selectList(new LambdaQueryWrapper<SysTenantPO>()
                 .in(SysTenantPO::getPackageId, ids));

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantServiceImpl.java

@@ -102,7 +102,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
     }
 
     @Override
-    public int deleteSysTenantByIds(Collection<String> ids) {
+    public int removeSysTenantByIds(Collection<String> ids) {
         return tenantRepository.deleteBatchIds(ids);
     }
 

+ 24 - 15
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/provider/SysMenuApiProvider.java

@@ -41,24 +41,29 @@ public class SysMenuApiProvider implements SysMenuApi {
         Map<String, SysMenuDTO> menuMapById = flatTree.stream()
                 .collect(Collectors.groupingBy(SysMenuDTO::getId, Collectors.collectingAndThen(Collectors.toList(), CollUtil::getFirst)));
         //参数校验
-        parentId=StrUtil.isEmpty(parentId)?"0":parentId;
+        String tempParentId=StrUtil.isEmpty(parentId)?"0":parentId;
+        SysMenuDTO tempParent=null;
         if(!StrUtil.equals(parentId,"0")) {
             SysMenuDTO parentMenu = menuMapById.get(parentId);
             if(ObjectUtil.isEmpty(parentMenu)) {
                 throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,String.format("上级菜单不存在,id值为:{%s}", parentId));
             }
-        }else {
-            while (!StrUtil.equals(parentId,"0")||StrUtil.isEmpty(parentId)){
-                SysMenuDTO parentMenu = menuMapById.get(parentId);
-                if(StrUtil.isNotEmpty(parentMenu.getRoutePath())){
-                    paths.add(0,parentMenu.getRoutePath());
+            while (!StrUtil.equals(tempParentId,"0")||StrUtil.isEmpty(tempParentId)){
+                SysMenuDTO parent = menuMapById.get(tempParentId);
+                tempParent=Objects.isNull(tempParent)?parentMenu:tempParent;
+                if(StrUtil.isNotEmpty(parent.getRoutePath())){
+                    paths.add(0,parent.getRoutePath());
                 }
-                parentId=parentMenu.getParentId();
+                tempParentId=parent.getParentId();
             }
         }
-        String routePath=frontModuleName+StrUtil.upperFirst(busName);
-        String prefix="/"+frontModuleName+"/"+CollectionUtil.join(paths,"/");
-        String componentPath=prefix+busName+"/index";
+        //组件路径 {moduleName}/{menuRouteName}/{menuRouterName}/{busName}/Xxx/
+        String componentPath="";
+        if(CollectionUtil.isNotEmpty(paths)){
+            componentPath=componentPath+CollectionUtil.join(paths,"/");
+        }else {
+            componentPath=frontModuleName+"/"+StrUtil.upperFirst(busName);
+        }
         SysMenuPO menu = menuRepository.selectOne(new LambdaQueryWrapper<SysMenuPO>()
                 .eq(SysMenuPO::getName, functionName)
                 .eq(SysMenuPO::getMenuType, "menu"));
@@ -68,13 +73,17 @@ public class SysMenuApiProvider implements SysMenuApi {
             insert=true;
             menu=new SysMenuPO();
         }
-
-
+        String routePath="";
+        if(Objects.nonNull(tempParent)){
+            routePath=tempParent.getRoutePath()+StrUtil.upperFirst(busName);
+        }else {
+            routePath=frontModuleName+StrUtil.upperFirst(busName);
+        }
         // 插入新菜单
         menu.setMenuType("menu");
         menu.setName(functionName);
         menu.setRoutePath(routePath);
-        menu.setComponent(componentPath);
+        menu.setComponent(componentPath+"/index");
         menu.setParentId(parentId);
         menu.setKeepalive(true);
         menu.setLinkExternal(false);
@@ -87,8 +96,8 @@ public class SysMenuApiProvider implements SysMenuApi {
         if(insert){
             menuService.insertSysMenu(menuDTO);
             menu = menuRepository.selectOne(new LambdaQueryWrapper<SysMenuPO>()
-                            .eq(SysMenuPO::getName, functionName)
-                            .eq(SysMenuPO::getMenuType, "menu"));
+                    .eq(SysMenuPO::getName, functionName)
+                    .eq(SysMenuPO::getMenuType, "menu"));
             addForGenButton(menu.getId(),permissionPrefix,functionName);
 
         }else {

+ 1 - 0
tr-plugins/tr-spring-boot-starter-plugin-web/src/main/java/cn/tr/plugin/web/config/TrWebMvcConfig.java

@@ -51,6 +51,7 @@ public class TrWebMvcConfig implements WebMvcConfigurer {
             }
         });
         objectMapper.setDateFormat(new SimpleDateFormat(jacksonProperties.getDateFormat()));
+        objectMapper.setTimeZone(jacksonProperties.getTimeZone());
         converter.setObjectMapper(objectMapper);
         converters.add(0, converter);
     }

+ 2 - 1
tr-test/src/main/resources/application.yml

@@ -49,7 +49,8 @@ spring:
   profiles:
     include: doc
   jackson:
-    date-format: yyyy-mm-dd HH:mm:ss
+    date-format: yyyy-MM-dd HH:mm:ss
+    time-zone: GMT-8
 
 
 tr: