shiqian il y a 4 ans
Parent
commit
6cef9c20bd

+ 4 - 0
boman-api/boman-api-gen/src/main/java/com/boman/gen/api/RemoteGenTableColumnService.java

@@ -7,6 +7,8 @@ import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 
+import java.util.List;
+
 /**
  * 生成代码模块,远程调用入口,如需其他接口,在此添加
  *
@@ -29,5 +31,7 @@ public interface RemoteGenTableColumnService {
     @GetMapping(value = "/genTableColumn/pk/{columnId}")
     GenTableColumn getById(@PathVariable("columnId") Long columnId);
 
+    @GetMapping(value = "/genTableColumn/listColumnsByTableName/{tableName}")
+    List<GenTableColumn> listColumnsByTableName(@PathVariable("tableName") String tableName);
 
 }

+ 3 - 7
boman-api/boman-api-jflow/src/main/java/com/boman/jflow/api/RemoteJflowService.java

@@ -1,19 +1,15 @@
 package com.boman.jflow.api;
 
-import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.constant.ServiceNameConstants;
-import com.boman.domain.dto.ProcessDto;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 
 /**
  * @author shiqian
  * @date 2021年05月26日 15:09
  **/
-@FeignClient(contextId = "remoteJflowService", value = ServiceNameConstants.JFLOW_SERVICE)
+@FeignClient(contextId = "remoteJflowService", name = ServiceNameConstants.JFLOW_SERVICE)
 public interface RemoteJflowService {
 
-    @PostMapping(name = "/jflow/p/cs/process/launch")
-    JSONObject createProcess(@RequestBody ProcessDto dto);
+//    @PostMapping(name = "/jflow/p/cs/process/launch")
+//    JSONObject createProcess(@RequestBody ProcessDto dto);
 }

+ 16 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/dto/ProcessDto.java

@@ -0,0 +1,16 @@
+package com.boman.domain.dto;
+
+
+/**
+ * @author shiqian
+ * @date 2021年05月26日 15:29
+ **/
+public class ProcessDto {
+
+    /** 主键 **/
+    private Long businessCode;
+
+    /** 表名 **/
+    private String dbname;
+
+}

+ 1 - 0
boman-api/pom.xml

@@ -13,6 +13,7 @@
         <module>boman-api-gen</module>
         <module>boman-domain</module>
         <module>boman-api-web-core</module>
+        <module>boman-api-jflow</module>
     </modules>
 
     <artifactId>boman-api</artifactId>

+ 17 - 0
boman-modules/boman-system/pom.xml

@@ -96,6 +96,23 @@
             <version>2.5.0-SNAPSHOT</version>
         </dependency>
 
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba.cloud</groupId>-->
+<!--            <artifactId>spring-cloud-starter-alibaba-seata</artifactId>-->
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <groupId>io.seata</groupId>-->
+<!--                    <artifactId>seata-spring-boot-starter</artifactId>-->
+<!--                </exclusion>-->
+<!--            </exclusions>-->
+<!--        </dependency>-->
+
+<!--        <dependency>-->
+<!--            <groupId>io.seata</groupId>-->
+<!--            <artifactId>seata-spring-boot-starter</artifactId>-->
+<!--            <version>1.4.0</version>-->
+<!--        </dependency>-->
+
     </dependencies>
 
     <build>

+ 3 - 0
boman-modules/boman-system/src/main/java/com/boman/system/RuoYiSystemApplication.java

@@ -1,6 +1,8 @@
 package com.boman.system;
 
 import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.cloud.client.SpringCloudApplication;
 import com.boman.common.security.annotation.EnableCustomConfig;
 import com.boman.common.security.annotation.EnableRyFeignClients;
@@ -15,6 +17,7 @@ import com.boman.common.swagger.annotation.EnableCustomSwagger2;
 @EnableCustomSwagger2
 @EnableRyFeignClients
 @SpringCloudApplication
+//@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
 public class RuoYiSystemApplication
 {
     public static void main(String[] args)

+ 70 - 0
boman-modules/boman-system/src/main/java/com/boman/system/config/DataSourceProxyConfig.java

@@ -0,0 +1,70 @@
+//package com.boman.system.config;
+//
+//import com.alibaba.druid.pool.DruidDataSource;
+//import io.seata.rm.datasource.DataSourceProxy;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.cloud.context.config.annotation.RefreshScope;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.Primary;
+//
+//import javax.sql.DataSource;
+//
+///**
+// * 对分布式事务seata配置的数据源代理
+// *
+// * @author hanguilin
+// */
+//@Configuration
+//public class DataSourceProxyConfig {
+//
+//    @Value("${spring.datasource.dynamic.datasource.master.url}")
+//    private String url;
+//    @Value("${spring.datasource.dynamic.datasource.master.username}")
+//    private String username;
+//    @Value("${spring.datasource.dynamic.datasource.master.password}")
+//    private String password;
+//
+//    @Bean
+//    @ConfigurationProperties(prefix = "spring.datasource")
+//    @RefreshScope
+//    public DataSource getDataSource() {
+//        DruidDataSource dataSource = new DruidDataSource();
+//        dataSource.setUrl(url);
+//        dataSource.setUsername(username);
+//        dataSource.setPassword(password);
+//        return dataSource;
+//    }
+//
+//    @Primary
+//    @Bean("dataSource")
+//    public DataSourceProxy dataSourceProxy(DataSource druidDataSource) {
+//        return new DataSourceProxy(druidDataSource);
+//    }
+//
+//    public String getUrl() {
+//        return url;
+//    }
+//
+//    public void setUrl(String url) {
+//        this.url = url;
+//    }
+//
+//    public String getUsername() {
+//        return username;
+//    }
+//
+//    public void setUsername(String username) {
+//        this.username = username;
+//    }
+//
+//    public String getPassword() {
+//        return password;
+//    }
+//
+//    public void setPassword(String password) {
+//        this.password = password;
+//    }
+//}

+ 22 - 23
boman-modules/boman-system/src/main/java/com/boman/system/controller/TableController.java

@@ -1,12 +1,11 @@
 //package com.boman.system.controller;
 //
-//import com.boman.common.core.web.domain.AjaxResult;
-//import com.boman.system.common.BaseTableSaveDTO;
-//import com.boman.system.common.TableServiceCmdService;
-//import io.swagger.annotations.ApiOperation;
+//import com.boman.system.api.RemoteDeptService;
+//import com.boman.system.api.RemoteMenuService;
+//import com.boman.system.api.RemoteUserService;
+//import io.seata.spring.annotation.GlobalTransactional;
 //import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.web.bind.annotation.PostMapping;
-//import org.springframework.web.bind.annotation.RequestBody;
+//import org.springframework.web.bind.annotation.GetMapping;
 //import org.springframework.web.bind.annotation.RequestMapping;
 //import org.springframework.web.bind.annotation.RestController;
 //
@@ -17,26 +16,26 @@
 // * @date 2021年03月22日 09:19
 // **/
 //@RestController
-//@RequestMapping("/p/cs/table")
+//@RequestMapping
 //public class TableController {
 //
+////    @Autowired
+////    private TableServiceCmdService tableServiceCmdService;
+//
+//    @Autowired
+//    private RemoteDeptService remoteDeptService;
 //    @Autowired
-//    private TableServiceCmdService tableServiceCmdService;
-//
-//    /**
-//     * 功能描述: 反提交接口, 更改的字段类型和字段值都是一致的
-//     *                {
-//     *                    "table": "sys_config",
-//     *                }
-//     *
-//     *
-//     * @param condition condition
-//     * @return com.boman.common.core.web.domain.AjaxResult
-//     */
-//    @ApiOperation(value = "根据表名获取表单所有信息")
-//    @PostMapping("/getByTableName")
-//    public AjaxResult getByTableName(@RequestBody BaseTableSaveDTO condition) {
-//        return tableServiceCmdService.getByTableName(condition);
+//    private RemoteUserService remoteUserService;
+//
+//
+//
+//    @GetMapping("sq")
+//    @GlobalTransactional(rollbackFor = Exception.class)
+//    public String getByTableName() {
+//        int update = remoteDeptService.update();
+//        int update1 = remoteUserService.update();
+//        int i = 1/0;
+//        return "";
 //    }
 //
 //

+ 2 - 4
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysRoleMenuServiceImpl.java

@@ -74,14 +74,12 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
 
             ISysRoleMenuService proxyService = ProxyUtils.proxy();
             List<String> head = dto.getHead();
-            List<Long> menuIdList;
-            List<SysRoleMenu> roleMenuList;
             if (isNotEmpty(head)) {
                 // 根据子菜单和前台传过来的head来判断包含AMD...中的哪些
                 childList = buildBtnByHead(head, childList);
                 List<Long> childIdList = map(childList, SysMenu::getId);
-                roleMenuList = buildRoleMenu(roleId, childIdList);
-                menuIdList = CollectionUtils.addAllDistinct(childIdList, map(originChildList, SysMenu::getId));
+                List<SysRoleMenu> roleMenuList = buildRoleMenu(roleId, childIdList);
+                List<Long> menuIdList = CollectionUtils.addAllDistinct(childIdList, map(originChildList, SysMenu::getId));
                 try {
                     // 先删除,再添加,防止联合索引报错
                     proxyService.deleteByRoleIdList(Collections.singletonList(roleId), menuIdList);

+ 6 - 0
boman-web-core/pom.xml

@@ -100,6 +100,12 @@
             <version>2.5.0-SNAPSHOT</version>
         </dependency>
 
+        <!--        远程调用 jflow-->
+        <dependency>
+            <groupId>com.boman</groupId>
+            <artifactId>boman-api-jflow</artifactId>
+            <version>2.5.0-SNAPSHOT</version>
+        </dependency>
 
     </dependencies>
 

+ 13 - 1
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -18,6 +18,7 @@ import com.boman.domain.dto.RoleMenuDto;
 import com.boman.domain.exception.NoSuchFunctionException;
 import com.boman.gen.api.RemoteGenTableColumnService;
 import com.boman.gen.api.RemoteGenTableService;
+import com.boman.jflow.api.RemoteJflowService;
 import com.boman.system.api.RemoteMenuService;
 import com.boman.system.api.domain.SysMenu;
 import com.boman.web.core.domain.ActionType;
@@ -86,6 +87,8 @@ public class TableServiceCmdService {
     private RemoteGenTableColumnService remoteGenTableColumnService;
     @Resource
     private RemoteMenuService remoteMenuService;
+    @Resource
+    private RemoteJflowService remoteJflowService;
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
 
@@ -105,7 +108,7 @@ public class TableServiceCmdService {
         AjaxResult result;
         // 新增
         if (ActionType.INSERT.equals(context.getActionType())) {
-            Integer maxId = IdUtils.getMaxId(dto.getTable(), pkName);
+            Long maxId = IdUtils.getMaxId(dto.getTable(), pkName);
             RowResult rowResult = saveService.insertRow(context, maxId);
             if (RowResult.checkSuccess(rowResult)) {
                 LOGGER.info("保存成功,封装到数据库的数据为: {}", JSON.toJSONString(rowResult.getData()));
@@ -543,6 +546,15 @@ public class TableServiceCmdService {
         // 先去查出之前的状态
         List<Long> idList = map(commitData, jsonObject -> jsonObject.getLong(FormDataConstant.ID));
 
+//        for (Long id : idList) {
+//            ProcessDto dto = new ProcessDto();
+//            dto.setDbname(condition.getTable());
+//            dto.setBusinessCode(id);
+//            JSONObject process = remoteJflowService.createProcess(dto);
+//
+//        }
+
+
         List<JSONObject> beforeList = selectService.selectByIdList(tableName, pkName, idList, Lists.newArrayList(pkName, STATUS));
         requireNonNull(beforeList, "beforeList is empty");