remove hmily-admin

This commit is contained in:
yu199195 2020-08-10 11:44:31 +08:00
parent 593ea3ceb0
commit 752ae3530f
52 changed files with 6 additions and 33721 deletions

2
.gitignore vendored
View File

@ -37,8 +37,6 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.gitignore
# other ignore
*.log
*.tmp

View File

@ -1,171 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.dromara</groupId>
<artifactId>hmily</artifactId>
<version>2.0.6-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hmily-admin</artifactId>
<dependencies>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>hmily-common</artifactId>
</dependency>
<!--spring boot的核心启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--aop支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!--自动配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>org.dromara.hmily.admin.AdminApplication</mainClass>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
<useDefaultDelimiters>true</useDefaultDelimiters>
</configuration>
</plugin>
<!-- maven install 跳过测试 等价于命令 mvn install -Dmaven.test.skip = true-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,40 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
/**
* hmily tcc start.
* @author xiaoyu
*/
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
public class AdminApplication {
/**
* main start.
* @param args args
*/
public static void main(final String[] args) {
SpringApplication.run(AdminApplication.class, args);
}
}

View File

@ -1,40 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Permission.
* @author xiaoyu(Myth)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Permission {
/**
* is login.
*
* @return true
*/
boolean isLogin() default true;
}

View File

@ -1,95 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.controller;
import org.dromara.hmily.admin.annotation.Permission;
import org.dromara.hmily.admin.dto.CompensationDTO;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.ApplicationNameService;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.utils.httpclient.AjaxResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* transaction log rest controller.
* @author xiaoyu(Myth)
*/
@RestController
@RequestMapping("/compensate")
public class CompensationController {
private final CompensationService compensationService;
private final ApplicationNameService applicationNameService;
@Value("${compensation.retry.max}")
private Integer recoverRetryMax;
@Autowired
public CompensationController(final CompensationService compensationService,
final ApplicationNameService applicationNameService) {
this.compensationService = compensationService;
this.applicationNameService = applicationNameService;
}
@Permission
@PostMapping(value = "/listPage")
public AjaxResponse listPage(@RequestBody final CompensationQuery recoverQuery) {
final CommonPager<HmilyCompensationVO> pager =
compensationService.listByPage(recoverQuery);
return AjaxResponse.success(pager);
}
@PostMapping(value = "/batchRemove")
@Permission
public AjaxResponse batchRemove(@RequestBody final CompensationDTO compensationDTO) {
final Boolean success = compensationService.batchRemove(compensationDTO.getIds(),
compensationDTO.getApplicationName());
return AjaxResponse.success(success);
}
@PostMapping(value = "/update")
@Permission
public AjaxResponse update(@RequestBody final CompensationDTO compensationDTO) {
if (recoverRetryMax < compensationDTO.getRetry()) {
return AjaxResponse.error("重试次数超过最大设置,请您重新设置!");
}
final Boolean success = compensationService.updateRetry(compensationDTO.getId(),
compensationDTO.getRetry(), compensationDTO.getApplicationName());
return AjaxResponse.success(success);
}
@PostMapping(value = "/listAppName")
@Permission
public AjaxResponse listAppName() {
final List<String> list = applicationNameService.list();
return AjaxResponse.success(list);
}
}

View File

@ -1,54 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.controller;
import org.dromara.hmily.admin.dto.UserDTO;
import org.dromara.hmily.admin.service.LoginService;
import org.dromara.hmily.common.utils.httpclient.AjaxResponse;
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.RestController;
/**
* login rest controller.
*
* @author xiaoyu(Myth)
*/
@RestController
public class LoginController {
private final LoginService loginService;
@Autowired
public LoginController(final LoginService loginService) {
this.loginService = loginService;
}
@PostMapping("/login")
public AjaxResponse login(@RequestBody final UserDTO userDTO) {
final Boolean login = loginService.login(userDTO.getUserName(), userDTO.getPassword());
return AjaxResponse.success(login);
}
@PostMapping("/logout")
public AjaxResponse logout() {
return AjaxResponse.success(loginService.logout());
}
}

View File

@ -1,42 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* CompensationDTO.
* @author xiaoyu(Myth)
*/
@Data
public class CompensationDTO implements Serializable {
private static final long serialVersionUID = 6905402148490426011L;
private String applicationName;
private List<String> ids;
private String id;
private Integer retry;
}

View File

@ -1,37 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.dto;
import lombok.Data;
import java.io.Serializable;
/**
* UserDTO.
* @author xiaoyu(Myth)
*/
@Data
public class UserDTO implements Serializable {
private static final long serialVersionUID = -3479973014221253748L;
private String userName;
private String password;
}

View File

@ -1,62 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.filter;
import org.springframework.stereotype.Component;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* cors filter .
* @author xiaoyu(Myth)
*/
@Component
public class CorsFilter implements Filter {
@Override
public void init(final FilterConfig filterConfig) {
}
@Override
public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
response.setHeader("Access-Control-Request-Headers", "content-type");
chain.doFilter(req, res);
}
@Override
public void destroy() {
}
}

View File

@ -1,51 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.helper;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.bean.adapter.CoordinatorRepositoryAdapter;
import org.dromara.hmily.common.utils.DateUtils;
/**
* ConvertHelper.
*
* @author xiaoyu(Myth)
*/
public class ConvertHelper {
/**
* build TccCompensationVO.
*
* @param adapter {@linkplain CoordinatorRepositoryAdapter}
* @return {@linkplain HmilyCompensationVO}
*/
public static HmilyCompensationVO buildVO(final CoordinatorRepositoryAdapter adapter) {
HmilyCompensationVO vo = new HmilyCompensationVO();
vo.setTransId(adapter.getTransId());
vo.setCreateTime(DateUtils.parseDate(adapter.getCreateTime()));
vo.setRetriedCount(adapter.getRetriedCount());
vo.setLastTime(DateUtils.parseDate(adapter.getLastTime()));
vo.setVersion(adapter.getVersion());
vo.setTargetClass(adapter.getTargetClass());
vo.setTargetMethod(adapter.getTargetMethod());
vo.setConfirmMethod(adapter.getConfirmMethod());
vo.setCancelMethod(adapter.getCancelMethod());
return vo;
}
}

View File

@ -1,111 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.helper;
import org.dromara.hmily.admin.page.PageParameter;
/**
* ConvertHelper.
*
* @author xiaoyu(Myth)
* @version 1.0
*/
@SuppressWarnings("ALL")
public class PageHelper {
/**
* build PageParameter.
*
* @param pageParameter pageParameter
* @param totalCount totalCount
* @return {@linkplain PageParameter}
*/
public static PageParameter buildPage(final PageParameter pageParameter, final int totalCount) {
final int currentPage = pageParameter.getCurrentPage();
pageParameter.setTotalCount(totalCount);
int totalPage = totalCount / pageParameter.getPageSize()
+ ((totalCount % pageParameter.getPageSize() == 0) ? 0 : 1);
pageParameter.setTotalPage(totalPage);
pageParameter.setPrePage(currentPage - 1);
pageParameter.setNextPage(currentPage + 1);
return pageParameter;
}
/**
* sqlserver page.
*
* @param sql sql
* @param page page
* @return String
*/
public static StringBuilder buildPageSqlForSqlserver(final String sql, final PageParameter page) {
StringBuilder pageSql = new StringBuilder(100);
String start = String.valueOf((page.getCurrentPage() - 1) * page.getPageSize());
pageSql.append(sql);
pageSql.append(" order by 1");
pageSql.append(" offset ")
.append(start)
.append(" rows fetch next ")
.append(page.getPageSize())
.append(" rows only ");
return pageSql;
}
/**
* mysql build page sql.
*
* @param sql sql
* @param page page
* @return String
*/
public static StringBuilder buildPageSqlForMysql(final String sql, final PageParameter page) {
StringBuilder pageSql = new StringBuilder(100);
String start = String.valueOf((page.getCurrentPage() - 1) * page.getPageSize());
pageSql.append(sql);
pageSql.append(" limit ").append(start).append(",").append(page.getPageSize());
return pageSql;
}
/**
* oracle page sql.
*
* @param sql sql
* @param page page
* @return String
*/
public static StringBuilder buildPageSqlForOracle(final String sql, final PageParameter page) {
StringBuilder pageSql = new StringBuilder(100);
String start = String.valueOf((page.getCurrentPage() - 1) * page.getPageSize());
String end = String.valueOf(page.getCurrentPage() * page.getPageSize());
pageSql.append("select * from ( select temp.*, rownum row_id from ( ");
pageSql.append(sql).append(" ) temp where rownum <= ").append(end);
pageSql.append(" ) where row_id > ").append(start);
return pageSql;
}
public static StringBuilder buildPageSqlForPostgreSQL(final String sql, final PageParameter page) {
StringBuilder pageSql = new StringBuilder(100);
String start = String.valueOf((page.getCurrentPage() - 1) * page.getPageSize());
pageSql.append(sql);
pageSql.append(" limit ").append(page.getPageSize()).append(" offset ").append(start);
return pageSql;
}
}

View File

@ -1,59 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.interceptor;
import org.dromara.hmily.admin.annotation.Permission;
import org.dromara.hmily.admin.service.login.LoginServiceImpl;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Objects;
/**
* AuthInterceptor.
*
* @author xiaoyu(Myth)
*/
public class AuthInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(final HttpServletRequest request,
final HttpServletResponse response,
final Object handler) throws Exception {
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
final Permission annotation = method.getAnnotation(Permission.class);
if (Objects.isNull(annotation)) {
return Boolean.TRUE;
}
final boolean login = annotation.isLogin();
if (login && !LoginServiceImpl.LOGIN_SUCCESS) {
request.setAttribute("code", "404");
request.setAttribute("msg", "请您先登录!");
request.getRequestDispatcher("/").forward(request, response);
return Boolean.FALSE;
}
}
return super.preHandle(request, response, handler);
}
}

View File

@ -1,44 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.page;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* common Pager.
* @author xiaoyu
*/
@Data
public class CommonPager<T> implements Serializable {
private static final long serialVersionUID = -1220101004792874251L;
/**
* page.
*/
private PageParameter page;
/**
* data.
*/
private List<T> dataList;
}

View File

@ -1,66 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.page;
import lombok.Data;
import java.io.Serializable;
/**
* PageParameter.
* @author xiaoyu(Myth)
*/
@Data
public class PageParameter implements Serializable {
private static final long serialVersionUID = -8324693985921606090L;
private static final int DEFAULT_PAGE_SIZE = 10;
private int pageSize;
private int currentPage;
private int prePage;
private int nextPage;
private int totalPage;
private int totalCount;
public PageParameter() {
this.currentPage = 1;
this.pageSize = DEFAULT_PAGE_SIZE;
}
/**
* PageParameter.
* @param currentPage current page.
* @param pageSize page size.
*/
public PageParameter(final int currentPage, final int pageSize) {
this.currentPage = currentPage;
this.pageSize = pageSize;
}
public int getCurrentPage() {
return currentPage;
}
}

View File

@ -1,55 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.query;
import lombok.Data;
import org.dromara.hmily.admin.page.PageParameter;
import java.io.Serializable;
/**
* query condition.
* @author xiaoyu(Myth)
*/
@Data
public class CompensationQuery implements Serializable {
private static final long serialVersionUID = 3297929795348894462L;
/**
* app name.
*/
private String applicationName;
/**
* transId.
*/
private String transId;
/**
* retry.
*/
private Integer retry;
/**
* pageParameter.
*/
private PageParameter pageParameter;
}

View File

@ -1,35 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service;
import java.util.List;
/**
* ApplicationNameService.
* @author xiaoyu(Myth)
*/
@FunctionalInterface
public interface ApplicationNameService {
/**
* acquired app name.
*
* @return app name list.
*/
List<String> list();
}

View File

@ -1,60 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import java.util.List;
/**
* compensation log Service.
*
* @author xiaoyu(Myth)
*/
public interface CompensationService {
/**
* acquired {@linkplain HmilyCompensationVO} by page.
*
* @param query {@linkplain CompensationQuery}
* @return CommonPager TransactionRecoverVO
*/
CommonPager<HmilyCompensationVO> listByPage(CompensationQuery query);
/**
* batch remove transaction log by ids.
*
* @param ids ids pk ids
* @param appName app name
* @return true success
*/
Boolean batchRemove(List<String> ids, String appName);
/**
* modify retry count.
*
* @param id transId
* @param retry retry
* @param appName appName
* @return true success
*/
Boolean updateRetry(String id, Integer retry, String appName);
}

View File

@ -1,39 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service;
/**
* LoginService.
* @author xiaoyu(Myth)
*/
public interface LoginService {
/**
* login.
* @param userName userName
* @param password password
* @return true success
*/
Boolean login(String userName, String password);
/**
* logout.
* @return true success
*/
Boolean logout();
}

View File

@ -1,41 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import com.google.common.base.Splitter;
import org.dromara.hmily.admin.service.ApplicationNameService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* ApplicationNameServiceImpl.
* @author xiaoyu(Myth)
*/
@Service("recoverApplicationNameService")
public class ApplicationNameServiceImpl implements ApplicationNameService {
@Value("${compensation.application.list}")
private String appNameList;
@Override
public List<String> list() {
return Splitter.on(",").splitToList(appNameList);
}
}

View File

@ -1,198 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import org.dromara.hmily.common.utils.CollectionUtils;
import org.dromara.hmily.common.utils.StringUtils;
import org.dromara.hmily.admin.helper.ConvertHelper;
import org.dromara.hmily.admin.helper.PageHelper;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.bean.adapter.CoordinatorRepositoryAdapter;
import org.dromara.hmily.common.exception.HmilyException;
import org.dromara.hmily.common.serializer.ObjectSerializer;
import org.dromara.hmily.common.utils.DateUtils;
import org.dromara.hmily.common.utils.FileUtils;
import org.dromara.hmily.common.utils.RepositoryPathUtils;
import java.io.File;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* file impl.
*
* @author xiaoyu(Myth)
*/
@SuppressWarnings("all")
public class FileCompensationServiceImpl implements CompensationService {
private final ObjectSerializer objectSerializer;
public FileCompensationServiceImpl(final ObjectSerializer objectSerializer) {
this.objectSerializer = objectSerializer;
}
@Override
public CommonPager<HmilyCompensationVO> listByPage(final CompensationQuery query) {
final String filePath = RepositoryPathUtils.buildFilePath(query.getApplicationName());
final PageParameter pageParameter = query.getPageParameter();
final int currentPage = pageParameter.getCurrentPage();
final int pageSize = pageParameter.getPageSize();
int start = (currentPage - 1) * pageSize;
CommonPager<HmilyCompensationVO> voCommonPager = new CommonPager<>();
File path;
File[] files;
int totalCount;
List<HmilyCompensationVO> voList;
//如果只查 重试条件的
if (StringUtils.isBlank(query.getTransId()) && Objects.nonNull(query.getRetry())) {
path = new File(filePath);
files = path.listFiles();
final List<HmilyCompensationVO> all = findAll(files);
if (CollectionUtils.isNotEmpty(all)) {
final List<HmilyCompensationVO> collect =
all.stream().filter(Objects::nonNull)
.filter(vo -> vo.getRetriedCount() < query.getRetry())
.collect(Collectors.toList());
totalCount = collect.size();
voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList());
} else {
totalCount = 0;
voList = null;
}
} else if (StringUtils.isNoneBlank(query.getTransId()) && Objects.isNull(query.getRetry())) {
final String fullFileName = RepositoryPathUtils.getFullFileName(filePath, query.getTransId());
final File file = new File(fullFileName);
files = new File[]{file};
totalCount = files.length;
voList = findAll(files);
} else if (StringUtils.isNoneBlank(query.getTransId()) && Objects.nonNull(query.getRetry())) {
final String fullFileName = RepositoryPathUtils.getFullFileName(filePath, query.getTransId());
final File file = new File(fullFileName);
files = new File[]{file};
totalCount = files.length;
voList = findAll(files)
.stream().filter(Objects::nonNull)
.filter(vo -> vo.getRetriedCount() < query.getRetry())
.collect(Collectors.toList());
} else {
path = new File(filePath);
files = path.listFiles();
totalCount = Objects.requireNonNull(files).length;
voList = findByPage(files, start, pageSize);
}
voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount));
voCommonPager.setDataList(voList);
return voCommonPager;
}
@Override
public Boolean batchRemove(final List<String> ids, final String applicationName) {
if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
return Boolean.FALSE;
}
final String filePath = RepositoryPathUtils.buildFilePath(applicationName);
ids.stream().map(id ->
new File(RepositoryPathUtils.getFullFileName(filePath, id)))
.forEach(File::delete);
return Boolean.TRUE;
}
@Override
public Boolean updateRetry(final String id, final Integer retry, final String applicationName) {
if (StringUtils.isBlank(id)
|| StringUtils.isBlank(applicationName)
|| Objects.isNull(retry)) {
return false;
}
final String filePath = RepositoryPathUtils.buildFilePath(applicationName);
final String fullFileName = RepositoryPathUtils.getFullFileName(filePath, id);
final File file = new File(fullFileName);
final CoordinatorRepositoryAdapter adapter = readRecover(file);
if (Objects.nonNull(adapter)) {
try {
adapter.setLastTime(DateUtils.getDateYYYY());
} catch (Exception e) {
e.printStackTrace();
}
adapter.setRetriedCount(retry);
try {
FileUtils.writeFile(fullFileName, objectSerializer.serialize(adapter));
} catch (HmilyException e) {
e.printStackTrace();
return false;
}
return true;
}
return false;
}
private CoordinatorRepositoryAdapter readRecover(final File file) {
try {
try (FileInputStream fis = new FileInputStream(file)) {
byte[] content = new byte[(int) file.length()];
fis.read(content);
return objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class);
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private HmilyCompensationVO readTransaction(final File file) {
try {
try (FileInputStream fis = new FileInputStream(file)) {
byte[] content = new byte[(int) file.length()];
fis.read(content);
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class);
return ConvertHelper.buildVO(adapter);
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private List<HmilyCompensationVO> findAll(final File[] files) {
if (files != null && files.length > 0) {
return Arrays.stream(files)
.map(this::readTransaction)
.collect(Collectors.toList());
}
return null;
}
private List<HmilyCompensationVO> findByPage(final File[] files, final int start, final int pageSize) {
if (files != null && files.length > 0) {
return Arrays.stream(files).skip(start).limit(pageSize)
.map(this::readTransaction)
.collect(Collectors.toList());
}
return null;
}
}

View File

@ -1,148 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import lombok.RequiredArgsConstructor;
import org.dromara.hmily.common.utils.CollectionUtils;
import org.dromara.hmily.common.utils.StringUtils;
import org.dromara.hmily.admin.helper.PageHelper;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.constant.CommonConstant;
import org.dromara.hmily.common.utils.DateUtils;
import org.dromara.hmily.common.utils.DbTypeUtils;
import org.dromara.hmily.common.utils.RepositoryPathUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* jdbc impl.
*
* @author xiaoyu(Myth)
*/
@RequiredArgsConstructor
public class JdbcCompensationServiceImpl implements CompensationService {
@Autowired
private JdbcTemplate jdbcTemplate;
private String dbType;
@Override
public CommonPager<HmilyCompensationVO> listByPage(final CompensationQuery query) {
final String tableName = RepositoryPathUtils.buildDbTableName(query.getApplicationName());
final PageParameter pageParameter = query.getPageParameter();
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append("select trans_id,target_class,target_method,confirm_method,cancel_method,"
+ " retried_count,create_time,last_time,version from ")
.append(tableName).append(" where 1= 1 ");
if (StringUtils.isNoneBlank(query.getTransId())) {
sqlBuilder.append(" and trans_id = ").append(query.getTransId());
}
if (Objects.nonNull(query.getRetry())) {
sqlBuilder.append(" and retried_count < ").append(query.getRetry());
}
final String sql = buildPageSql(sqlBuilder.toString(), pageParameter);
CommonPager<HmilyCompensationVO> pager = new CommonPager<>();
final List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
if (CollectionUtils.isNotEmpty(mapList)) {
pager.setDataList(mapList.stream().map(this::buildByMap).collect(Collectors.toList()));
}
final Integer totalCount =
jdbcTemplate.queryForObject(String.format("select count(1) from %s", tableName), Integer.class);
if (Objects.nonNull(totalCount)) {
pager.setPage(PageHelper.buildPage(pageParameter, totalCount));
}
return pager;
}
@Override
public Boolean batchRemove(final List<String> ids, final String applicationName) {
if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
return Boolean.FALSE;
}
final String tableName = RepositoryPathUtils.buildDbTableName(applicationName);
ids.stream()
.map(id -> buildDelSql(tableName, id))
.forEach(jdbcTemplate::execute);
return Boolean.TRUE;
}
@Override
public Boolean updateRetry(final String id, final Integer retry, final String appName) {
if (StringUtils.isBlank(id) || StringUtils.isBlank(appName) || Objects.isNull(retry)) {
return false;
}
final String tableName = RepositoryPathUtils.buildDbTableName(appName);
String sqlBuilder =
String.format("update %s set retried_count = %d,last_time= '%s' where trans_id =%s",
tableName, retry, DateUtils.getCurrentDateTime(), id);
jdbcTemplate.execute(sqlBuilder);
return Boolean.TRUE;
}
private HmilyCompensationVO buildByMap(final Map<String, Object> map) {
HmilyCompensationVO vo = new HmilyCompensationVO();
vo.setTransId((String) map.get("trans_id"));
vo.setRetriedCount((Integer) map.get("retried_count"));
vo.setCreateTime(String.valueOf(map.get("create_time")));
vo.setLastTime(String.valueOf(map.get("last_time")));
vo.setVersion((Integer) map.get("version"));
vo.setTargetClass((String) map.get("target_class"));
vo.setTargetMethod((String) map.get("target_method"));
vo.setConfirmMethod((String) map.get("confirm_method"));
vo.setCancelMethod((String) map.get("cancel_method"));
return vo;
}
/**
* set db type.
*
* @param dbType dbType
*/
public void setDbType(final String dbType) {
this.dbType = DbTypeUtils.buildByDriverClassName(dbType);
}
private String buildPageSql(final String sql, final PageParameter pageParameter) {
switch (dbType) {
case CommonConstant.DB_MYSQL:
return PageHelper.buildPageSqlForMysql(sql, pageParameter).toString();
case CommonConstant.DB_ORACLE:
return PageHelper.buildPageSqlForOracle(sql, pageParameter).toString();
case CommonConstant.DB_SQLSERVER:
return PageHelper.buildPageSqlForSqlserver(sql, pageParameter).toString();
case CommonConstant.DB_POSTGRESQL:
return PageHelper.buildPageSqlForPostgreSQL(sql, pageParameter).toString();
default:
return "";
}
}
private String buildDelSql(final String tableName, final String id) {
return "DELETE FROM " + tableName + " WHERE trans_id=" + id;
}
}

View File

@ -1,120 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import com.mongodb.client.result.UpdateResult;
import lombok.RequiredArgsConstructor;
import org.dromara.hmily.common.utils.CollectionUtils;
import org.dromara.hmily.common.utils.StringUtils;
import org.dromara.hmily.admin.helper.ConvertHelper;
import org.dromara.hmily.admin.helper.PageHelper;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.bean.adapter.MongoAdapter;
import org.dromara.hmily.common.exception.HmilyRuntimeException;
import org.dromara.hmily.common.utils.DateUtils;
import org.dromara.hmily.common.utils.RepositoryPathUtils;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Mongodb impl.
* @author xiaoyu(Myth)
*/
@RequiredArgsConstructor
public class MongoCompensationServiceImpl implements CompensationService {
private final MongoTemplate mongoTemplate;
@Override
public CommonPager<HmilyCompensationVO> listByPage(final CompensationQuery query) {
CommonPager<HmilyCompensationVO> voCommonPager = new CommonPager<>();
final String mongoTableName = RepositoryPathUtils.buildMongoTableName(query.getApplicationName());
final PageParameter pageParameter = query.getPageParameter();
final int pageSize = pageParameter.getPageSize();
Query baseQuery = new Query();
if (StringUtils.isNoneBlank(query.getTransId())) {
baseQuery.addCriteria(new Criteria("transId").is(query.getTransId()));
}
if (Objects.nonNull(query.getRetry())) {
baseQuery.addCriteria(new Criteria("retriedCount").lt(query.getRetry()));
}
final long totalCount = mongoTemplate.count(baseQuery, mongoTableName);
if (totalCount <= 0) {
return voCommonPager;
}
final int currentPage = pageParameter.getCurrentPage();
int start = (currentPage - 1) * pageSize;
voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), (int) totalCount));
baseQuery.skip(start).limit(pageSize);
final List<MongoAdapter> mongoAdapters =
mongoTemplate.find(baseQuery, MongoAdapter.class, mongoTableName);
if (CollectionUtils.isNotEmpty(mongoAdapters)) {
final List<HmilyCompensationVO> recoverVOS =
mongoAdapters
.stream()
.map(ConvertHelper::buildVO)
.collect(Collectors.toList());
voCommonPager.setDataList(recoverVOS);
}
return voCommonPager;
}
@Override
public Boolean batchRemove(final List<String> ids, final String applicationName) {
if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
return Boolean.FALSE;
}
final String mongoTableName = RepositoryPathUtils.buildMongoTableName(applicationName);
ids.forEach(id -> {
Query query = new Query();
query.addCriteria(new Criteria("transId").is(id));
mongoTemplate.remove(query, mongoTableName);
});
return Boolean.TRUE;
}
@Override
public Boolean updateRetry(final String id, final Integer retry, final String appName) {
if (StringUtils.isBlank(id) || StringUtils.isBlank(appName) || Objects.isNull(retry)) {
return Boolean.FALSE;
}
final String mongoTableName = RepositoryPathUtils.buildMongoTableName(appName);
Query query = new Query();
query.addCriteria(new Criteria("transId").is(id));
Update update = new Update();
update.set("lastTime", DateUtils.getCurrentDateTime());
update.set("retriedCount", retry);
final UpdateResult updateResult = mongoTemplate.updateFirst(query, update,
MongoAdapter.class, mongoTableName);
if (updateResult.getModifiedCount() <= 0) {
throw new HmilyRuntimeException("更新数据异常!");
}
return Boolean.TRUE;
}
}

View File

@ -1,162 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import com.google.common.collect.Sets;
import org.dromara.hmily.admin.helper.ConvertHelper;
import org.dromara.hmily.admin.helper.PageHelper;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.bean.adapter.CoordinatorRepositoryAdapter;
import org.dromara.hmily.common.exception.HmilyException;
import org.dromara.hmily.common.jedis.JedisClient;
import org.dromara.hmily.common.serializer.ObjectSerializer;
import org.dromara.hmily.common.utils.DateUtils;
import org.dromara.hmily.common.utils.RepositoryPathUtils;
import lombok.RequiredArgsConstructor;
import org.dromara.hmily.common.utils.CollectionUtils;
import org.dromara.hmily.common.utils.StringUtils;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* redis impl.
* @author xiaoyu(Myth)
*/
@SuppressWarnings("unchecked")
@RequiredArgsConstructor
public class RedisCompensationServiceImpl implements CompensationService {
private final JedisClient jedisClient;
private final ObjectSerializer objectSerializer;
@Override
public CommonPager<HmilyCompensationVO> listByPage(final CompensationQuery query) {
CommonPager<HmilyCompensationVO> commonPager = new CommonPager<>();
final String redisKeyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(query.getApplicationName());
final int currentPage = query.getPageParameter().getCurrentPage();
final int pageSize = query.getPageParameter().getPageSize();
int start = (currentPage - 1) * pageSize;
Set<byte[]> keys;
List<HmilyCompensationVO> voList;
int totalCount;
//如果只查 重试条件的
if (StringUtils.isBlank(query.getTransId()) && Objects.nonNull(query.getRetry())) {
keys = jedisClient.keys((redisKeyPrefix + "*").getBytes());
final List<HmilyCompensationVO> all = findAll(keys);
final List<HmilyCompensationVO> collect =
all.stream()
.filter(vo -> vo.getRetriedCount() < query.getRetry())
.collect(Collectors.toList());
totalCount = collect.size();
voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList());
} else if (StringUtils.isNoneBlank(query.getTransId()) && Objects.isNull(query.getRetry())) {
keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes());
totalCount = keys.size();
voList = findAll(keys);
} else if (StringUtils.isNoneBlank(query.getTransId()) && Objects.nonNull(query.getRetry())) {
keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes());
totalCount = keys.size();
voList = findAll(keys)
.stream()
.filter(vo -> vo.getRetriedCount() < query.getRetry())
.collect(Collectors.toList());
} else {
keys = jedisClient.keys((redisKeyPrefix + "*").getBytes());
if (keys.size() <= 0 || keys.size() < start) {
return commonPager;
}
totalCount = keys.size();
voList = findByPage(keys, start, pageSize);
}
if (keys.size() <= 0 || keys.size() < start) {
return commonPager;
}
commonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount));
commonPager.setDataList(voList);
return commonPager;
}
private HmilyCompensationVO buildVOByKey(final byte[] key) {
final byte[] bytes = jedisClient.get(key);
try {
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(bytes, CoordinatorRepositoryAdapter.class);
return ConvertHelper.buildVO(adapter);
} catch (HmilyException e) {
e.printStackTrace();
return null;
}
}
@Override
public Boolean batchRemove(final List<String> ids, final String applicationName) {
if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
return Boolean.FALSE;
}
String keyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(applicationName);
final String[] keys = ids.stream()
.map(id -> RepositoryPathUtils.buildRedisKey(keyPrefix, id)).toArray(String[]::new);
jedisClient.del(keys);
return Boolean.TRUE;
}
@Override
public Boolean updateRetry(final String id, final Integer retry, final String appName) {
if (StringUtils.isBlank(id) || StringUtils.isBlank(appName) || Objects.isNull(retry)) {
return Boolean.FALSE;
}
String keyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(appName);
final String key = RepositoryPathUtils.buildRedisKey(keyPrefix, id);
final byte[] bytes = jedisClient.get(key.getBytes());
try {
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(bytes, CoordinatorRepositoryAdapter.class);
adapter.setRetriedCount(retry);
adapter.setLastTime(DateUtils.getDateYYYY());
jedisClient.set(key, objectSerializer.serialize(adapter));
return Boolean.TRUE;
} catch (Exception e) {
e.printStackTrace();
return Boolean.FALSE;
}
}
private List<HmilyCompensationVO> findAll(final Set<byte[]> keys) {
return keys.parallelStream()
.map(this::buildVOByKey)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
private List<HmilyCompensationVO> findByPage(final Set<byte[]> keys, final int start, final int pageSize) {
return keys.parallelStream()
.skip(start)
.limit(pageSize)
.map(this::buildVOByKey)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
}

View File

@ -1,180 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import com.google.common.collect.Lists;
import org.dromara.hmily.admin.helper.ConvertHelper;
import org.dromara.hmily.admin.helper.PageHelper;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.dromara.hmily.common.bean.adapter.CoordinatorRepositoryAdapter;
import org.dromara.hmily.common.exception.HmilyException;
import org.dromara.hmily.common.serializer.ObjectSerializer;
import org.dromara.hmily.common.utils.DateUtils;
import org.dromara.hmily.common.utils.RepositoryPathUtils;
import lombok.RequiredArgsConstructor;
import org.dromara.hmily.common.utils.CollectionUtils;
import org.dromara.hmily.common.utils.StringUtils;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* zookeeper impl.
*
* @author xiaoyu(Myth)
*/
@RequiredArgsConstructor
@SuppressWarnings("all")
public class ZookeeperCompensationServiceImpl implements CompensationService {
private final ZooKeeper zooKeeper;
private final ObjectSerializer objectSerializer;
@Override
public CommonPager<HmilyCompensationVO> listByPage(final CompensationQuery query) {
CommonPager<HmilyCompensationVO> voCommonPager = new CommonPager<>();
final int currentPage = query.getPageParameter().getCurrentPage();
final int pageSize = query.getPageParameter().getPageSize();
int start = (currentPage - 1) * pageSize;
final String rootPath = RepositoryPathUtils.buildZookeeperPathPrefix(query.getApplicationName());
List<String> zNodePaths;
List<HmilyCompensationVO> voList;
int totalCount;
try {
//如果只查 重试条件的
if (StringUtils.isBlank(query.getTransId()) && Objects.nonNull(query.getRetry())) {
zNodePaths = zooKeeper.getChildren(rootPath, false);
final List<HmilyCompensationVO> all = findAll(zNodePaths, rootPath);
final List<HmilyCompensationVO> collect =
all.stream()
.filter(vo -> vo.getRetriedCount() < query.getRetry())
.collect(Collectors.toList());
totalCount = collect.size();
voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList());
} else if (StringUtils.isNoneBlank(query.getTransId()) && Objects.isNull(query.getRetry())) {
zNodePaths = Lists.newArrayList(query.getTransId());
totalCount = zNodePaths.size();
voList = findAll(zNodePaths, rootPath);
} else if (StringUtils.isNoneBlank(query.getTransId()) && Objects.nonNull(query.getRetry())) {
zNodePaths = Lists.newArrayList(query.getTransId());
totalCount = zNodePaths.size();
voList = findAll(zNodePaths, rootPath)
.stream()
.filter(vo -> vo.getRetriedCount() < query.getRetry())
.collect(Collectors.toList());
} else {
zNodePaths = zooKeeper.getChildren(rootPath, false);
totalCount = zNodePaths.size();
voList = findByPage(zNodePaths, rootPath, start, pageSize);
}
voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount));
voCommonPager.setDataList(voList);
} catch (Exception e) {
e.printStackTrace();
}
return voCommonPager;
}
@Override
public Boolean batchRemove(final List<String> ids, final String appName) {
if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(appName)) {
return Boolean.FALSE;
}
final String rootPathPrefix = RepositoryPathUtils.buildZookeeperPathPrefix(appName);
ids.stream().map(id -> {
try {
final String path = RepositoryPathUtils.buildZookeeperRootPath(rootPathPrefix, id);
byte[] content = zooKeeper.getData(path,
false, new Stat());
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class);
zooKeeper.delete(path, adapter.getVersion());
return 1;
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}).count();
return Boolean.TRUE;
}
@Override
public Boolean updateRetry(final String id, final Integer retry, final String appName) {
if (StringUtils.isBlank(id) || StringUtils.isBlank(appName) || Objects.isNull(retry)) {
return Boolean.FALSE;
}
final String rootPathPrefix = RepositoryPathUtils.buildZookeeperPathPrefix(appName);
final String path = RepositoryPathUtils.buildZookeeperRootPath(rootPathPrefix, id);
try {
byte[] content = zooKeeper.getData(path,
false, new Stat());
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class);
adapter.setLastTime(DateUtils.getDateYYYY());
adapter.setRetriedCount(retry);
zooKeeper.create(path,
objectSerializer.serialize(adapter),
ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
return Boolean.TRUE;
} catch (Exception e) {
e.printStackTrace();
}
return Boolean.FALSE;
}
private List<HmilyCompensationVO> findAll(final List<String> zNodePaths, final String rootPath) {
return zNodePaths.stream()
.filter(StringUtils::isNoneBlank)
.map(zNodePath -> buildByNodePath(rootPath, zNodePath))
.collect(Collectors.toList());
}
private List<HmilyCompensationVO> findByPage(final List<String> zNodePaths, final String rootPath,
final int start, final int pageSize) {
return zNodePaths.stream()
.skip(start)
.limit(pageSize)
.filter(StringUtils::isNoneBlank)
.map(zNodePath -> buildByNodePath(rootPath, zNodePath))
.collect(Collectors.toList());
}
private HmilyCompensationVO buildByNodePath(final String rootPath, final String zNodePath) {
try {
byte[] content = zooKeeper.getData(RepositoryPathUtils.buildZookeeperRootPath(rootPath, zNodePath),
false, new Stat());
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class);
return ConvertHelper.buildVO(adapter);
} catch (KeeperException | InterruptedException | HmilyException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -1,62 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.login;
import org.dromara.hmily.admin.service.LoginService;
import org.dromara.hmily.common.utils.LogUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* LoginServiceImpl.
* @author xiaoyu(Myth)
*/
@Service("loginService")
public class LoginServiceImpl implements LoginService {
public static boolean LOGIN_SUCCESS = false;
/**
* logger.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(LoginServiceImpl.class);
@Value("${hmily.admin.userName}")
private String userName;
@Value("${hmily.admin.password}")
private String password;
@Override
public Boolean login(final String userName, final String password) {
LogUtil.info(LOGGER, "输入的用户名密码为:{}", () -> userName + "," + password);
if (userName.equals(this.userName) && password.equals(this.password)) {
LOGIN_SUCCESS = true;
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@Override
public Boolean logout() {
LOGIN_SUCCESS = false;
return Boolean.TRUE;
}
}

View File

@ -1,298 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.spi;
import com.google.common.base.Splitter;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.zaxxer.hikari.HikariDataSource;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.dromara.hmily.admin.interceptor.AuthInterceptor;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.service.compensate.FileCompensationServiceImpl;
import org.dromara.hmily.admin.service.compensate.JdbcCompensationServiceImpl;
import org.dromara.hmily.admin.service.compensate.MongoCompensationServiceImpl;
import org.dromara.hmily.admin.service.compensate.RedisCompensationServiceImpl;
import org.dromara.hmily.admin.service.compensate.ZookeeperCompensationServiceImpl;
import org.dromara.hmily.common.jedis.JedisClient;
import org.dromara.hmily.common.jedis.JedisClientCluster;
import org.dromara.hmily.common.jedis.JedisClientSentinel;
import org.dromara.hmily.common.jedis.JedisClientSingle;
import org.dromara.hmily.common.serializer.ObjectSerializer;
import org.dromara.hmily.common.utils.StringUtils;
import org.dromara.hmily.common.utils.extension.ExtensionLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.data.mongodb.core.MongoClientFactoryBean;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import javax.sql.DataSource;
import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* CompensationConfiguration.
*
* @author xiaoyu
*/
@Configuration
public class HmilyAdminConfiguration {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addInterceptors(final InterceptorRegistry registry) {
registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**");
}
};
}
@Configuration
static class SerializerConfiguration {
private final Environment env;
@Autowired
SerializerConfiguration(final Environment env) {
this.env = env;
}
@Bean
public ObjectSerializer objectSerializer() {
return ExtensionLoader.getExtensionLoader(ObjectSerializer.class)
.getActivateExtension(env.getProperty("compensation.serializer.support"));
}
}
/**
* spring.profiles.active = {}.
*/
@Configuration
@Profile("db")
static class JdbcRecoverConfiguration {
private final Environment env;
@Autowired
JdbcRecoverConfiguration(final Environment env) {
this.env = env;
}
@Bean
public DataSource dataSource() {
HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setDriverClassName(env.getProperty("compensation.db.driver"));
hikariDataSource.setJdbcUrl(env.getProperty("compensation.db.url"));
//用户名
hikariDataSource.setUsername(env.getProperty("compensation.db.username"));
//密码
hikariDataSource.setPassword(env.getProperty("compensation.db.password"));
hikariDataSource.setMinimumIdle(5);
hikariDataSource.setMaximumPoolSize(10);
return hikariDataSource;
}
@Bean
@Qualifier("jdbcTransactionRecoverService")
public CompensationService jdbcTransactionRecoverService() {
JdbcCompensationServiceImpl jdbcTransactionRecoverService = new JdbcCompensationServiceImpl();
jdbcTransactionRecoverService.setDbType(env.getProperty("compensation.db.driver"));
return jdbcTransactionRecoverService;
}
}
@Configuration
@Profile("redis")
static class RedisRecoverConfiguration {
private final Environment env;
private final ObjectSerializer objectSerializer;
@Autowired(required = false)
RedisRecoverConfiguration(final Environment env, final ObjectSerializer objectSerializer) {
this.env = env;
this.objectSerializer = objectSerializer;
}
@Bean
@Qualifier("redisTransactionRecoverService")
public CompensationService redisTransactionRecoverService() {
JedisPool jedisPool;
JedisPoolConfig config = new JedisPoolConfig();
JedisClient jedisClient;
final Boolean cluster = env.getProperty("compensation.redis.cluster", Boolean.class, Boolean.FALSE);
final Boolean sentinel = env.getProperty("compensation.redis.sentinel", Boolean.class, Boolean.FALSE);
final String password = env.getProperty("compensation.redis.password");
if (cluster) {
final String clusterUrl = env.getProperty("compensation.redis.clusterUrl");
assert clusterUrl != null;
final Set<HostAndPort> hostAndPorts = Splitter.on(";")
.splitToList(clusterUrl).stream()
.map(HostAndPort::parseString).collect(Collectors.toSet());
JedisCluster jedisCluster = new JedisCluster(hostAndPorts, config);
jedisClient = new JedisClientCluster(jedisCluster);
} else if (sentinel) {
final String sentinelUrl = env.getProperty("compensation.redis.sentinelUrl");
assert sentinelUrl != null;
final Set<String> hostAndPorts =
new HashSet<>(Splitter.on(";")
.splitToList(sentinelUrl));
final String master = env.getProperty("compensation.redis.master");
JedisSentinelPool pool =
new JedisSentinelPool(master, hostAndPorts,
config, password);
jedisClient = new JedisClientSentinel(pool);
} else {
final String port = env.getProperty("compensation.redis.port", "6379");
final String hostName = env.getProperty("compensation.redis.hostName");
if (StringUtils.isNoneBlank(password)) {
jedisPool = new JedisPool(config, hostName,
Integer.parseInt(port), 30, password);
} else {
jedisPool = new JedisPool(config, hostName,
Integer.parseInt(port), 30);
}
jedisClient = new JedisClientSingle(jedisPool);
}
return new RedisCompensationServiceImpl(jedisClient, objectSerializer);
}
}
@Configuration
@Profile("file")
static class FileRecoverConfiguration {
private final ObjectSerializer objectSerializer;
@Autowired(required = false)
FileRecoverConfiguration(final ObjectSerializer objectSerializer) {
this.objectSerializer = objectSerializer;
}
@Bean
@Qualifier("fileTransactionRecoverService")
public CompensationService fileTransactionRecoverService() {
return new FileCompensationServiceImpl(objectSerializer);
}
}
@Configuration
@Profile("zookeeper")
static class ZookeeperRecoverConfiguration {
private static final Lock LOCK = new ReentrantLock();
private final Environment env;
private final ObjectSerializer objectSerializer;
@Autowired(required = false)
ZookeeperRecoverConfiguration(final Environment env, final ObjectSerializer objectSerializer) {
this.env = env;
this.objectSerializer = objectSerializer;
}
@Bean
@Qualifier("zookeeperTransactionRecoverService")
public CompensationService zookeeperTransactionRecoverService() {
ZooKeeper zooKeeper = null;
try {
final String host = env.getProperty("compensation.zookeeper.host", "2181");
final String sessionTimeOut = env.getProperty("compensation.zookeeper.sessionTimeOut", "3000");
zooKeeper = new ZooKeeper(host, Integer.parseInt(sessionTimeOut), watchedEvent -> {
if (watchedEvent.getState() == Watcher.Event.KeeperState.SyncConnected) {
// 放开闸门, wait在connect方法上的线程将被唤醒
LOCK.unlock();
}
});
LOCK.lock();
} catch (Exception e) {
e.printStackTrace();
}
return new ZookeeperCompensationServiceImpl(zooKeeper, objectSerializer);
}
}
@Configuration
@Profile("mongo")
static class MongoRecoverConfiguration {
private final Environment env;
@Autowired
MongoRecoverConfiguration(final Environment env) {
this.env = env;
}
@Bean
@Qualifier("mongoTransactionRecoverService")
public CompensationService mongoTransactionRecoverService() {
MongoClientFactoryBean clientFactoryBean = new MongoClientFactoryBean();
final String userName = env.getProperty("compensation.mongo.userName", "xiaoyu");
final String dbName = env.getProperty("compensation.mongo.dbName", "col");
final String password = env.getProperty("compensation.mongo.password", "123456");
final String url = env.getProperty("compensation.mongo.url", "127.0.0.1");
MongoCredential credential = MongoCredential.createScramSha1Credential(
userName,
dbName,
password.toCharArray());
clientFactoryBean.setCredentials(new MongoCredential[]{credential});
List<String> urls = Splitter.on(",").trimResults().splitToList(url);
ServerAddress[] sds = new ServerAddress[urls.size()];
for (int i = 0; i < sds.length; i++) {
List<String> adds = Splitter.on(":").trimResults().splitToList(urls.get(i));
InetSocketAddress address = new InetSocketAddress(adds.get(0), Integer.parseInt(adds.get(1)));
sds[i] = new ServerAddress(address);
}
clientFactoryBean.setReplicaSetSeeds(sds);
MongoTemplate mongoTemplate = null;
try {
clientFactoryBean.afterPropertiesSet();
mongoTemplate = new MongoTemplate(Objects.requireNonNull(clientFactoryBean.getObject()),
dbName);
} catch (Exception e) {
e.printStackTrace();
}
return new MongoCompensationServiceImpl(mongoTemplate);
}
}
}

View File

@ -1,51 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.vo;
import lombok.Data;
import java.io.Serializable;
/**
* HmilyCompensationVO.
* @author xiaoyu(Myth)
*/
@Data
public class HmilyCompensationVO implements Serializable {
private static final long serialVersionUID = 564418979137349581L;
private String transId;
private Integer retriedCount;
private String createTime;
private String lastTime;
private Integer version;
private String targetClass;
private String targetMethod;
private String confirmMethod;
private String cancelMethod;
}

View File

@ -1,4 +0,0 @@
org.dromara.hmilyTCC.common.serializer.KryoSerializer
org.dromara.hmilyTCC.common.serializer.ProtostuffSerializer
org.dromara.hmilyTCC.common.serializer.HessianSerializer
org.dromara.hmilyTCC.common.serializer.JavaSerializer

View File

@ -1,6 +0,0 @@
compensation:
db:
driver : com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/tcc?useUnicode=true&amp;characterEncoding=utf8
username: root
password:

View File

@ -1,6 +0,0 @@
compensation:
mongo :
url : 192.168.1.68:27017
dbName : happylife
userName : xiaoyu
password : 123456

View File

@ -1,7 +0,0 @@
compensation:
redis:
cluster: false
# clusterUrl : 127.0.0.1:70001;127.0.1:7002
hostName : 192.168.1.68
port : 6379
password :

View File

@ -1,4 +0,0 @@
compensation:
zookeeper:
host : 192.168.1.132:2181
sessionTimeOut : 3000

View File

@ -1,23 +0,0 @@
server:
port: 8888
servlet:
context-path: /hmily-admin
spring:
application:
name: hmily-admin
profiles:
active: db
hmily:
admin :
userName : admin
password : admin
compensation:
application:
list : account-service,inventory-service,order-service
serializer :
support: kryo
retry :
max: 10

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,287 +0,0 @@
webpackJsonp([4],{
/***/ 117:
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(4)(true);
// imports
// module
exports.push([module.i, "\n.allcover {\n position: absolute;\n top: 0;\n right: 0;\n}\n.ctt {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.tb {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n.lr {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n.el-menu-item {\n min-width: inherit !important;\n}\n", "", {"version":3,"sources":["E:/parent/happylifeplat-tcc/happylifeplat-tcc-dashboard/src/page/manage.vue"],"names":[],"mappings":";AAAA;EACE,mBAAmB;EACnB,OAAO;EACP,SAAS;CACV;AACD;EACE,mBAAmB;EACnB,SAAS;EACT,UAAU;EACV,iCAAiC;CAClC;AACD;EACE,mBAAmB;EACnB,SAAS;EACT,4BAA4B;CAC7B;AACD;EACE,mBAAmB;EACnB,UAAU;EACV,4BAA4B;CAC7B;AACD;EACE,8BAA8B;CAC/B","file":"manage.vue","sourcesContent":[".allcover {\n position: absolute;\n top: 0;\n right: 0;\n}\n.ctt {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.tb {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n.lr {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n.el-menu-item {\n min-width: inherit !important;\n}\n"],"sourceRoot":""}]);
// exports
/***/ }),
/***/ 131:
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(117);
if(typeof content === 'string') content = [[module.i, content, '']];
if(content.locals) module.exports = content.locals;
// add the styles to the DOM
var update = __webpack_require__(8)("eec97438", content, false);
// Hot Module Replacement
if(true) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept(117, function() {
var newContent = __webpack_require__(117);
if(typeof newContent === 'string') newContent = [[module.i, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/***/ 132:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["a"] = ({
computed: {
defaultActive: function defaultActive() {
return this.$route.path.replace('/', '');
}
}
});
/***/ }),
/***/ 133:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ staticClass: "manage_page fillcontain" },
[
_c(
"el-row",
{ staticStyle: { height: "100%" } },
[
_c(
"el-col",
{
staticStyle: {
"min-height": "100%",
"background-color": "#324057"
},
attrs: { span: 3 }
},
[
_c(
"el-menu",
{
staticStyle: { "min-height": "100%" },
attrs: {
"default-active": _vm.defaultActive,
theme: "dark",
router: ""
}
},
[
_c("el-menu-item", { attrs: { index: "manage" } }, [
_c("i", { staticClass: "el-icon-menu" }),
_vm._v("首页")
]),
_vm._v(" "),
_c(
"el-submenu",
{ attrs: { index: "2" } },
[
_c(
"template",
{ attrs: { slot: "title" }, slot: "title" },
[
_c("i", { staticClass: "el-icon-plus" }),
_vm._v("事务补偿管理")
]
),
_vm._v(" "),
_c(
"el-menu-item",
{ attrs: { index: "transactionRecoveryInfo" } },
[_vm._v("事务补偿信息列表")]
)
],
2
),
_vm._v(" "),
_c(
"el-submenu",
{ attrs: { index: "3" } },
[
_c(
"template",
{ attrs: { slot: "title" }, slot: "title" },
[
_c("i", { staticClass: "el-icon-setting" }),
_vm._v("设置")
]
),
_vm._v(" "),
_c("el-menu-item", { attrs: { index: "adminSet" } }, [
_vm._v("管理员设置")
])
],
2
),
_vm._v(" "),
_c(
"el-submenu",
{ attrs: { index: "4" } },
[
_c(
"template",
{ attrs: { slot: "title" }, slot: "title" },
[
_c("i", { staticClass: "el-icon-warning" }),
_vm._v("说明")
]
),
_vm._v(" "),
_c("el-menu-item", { attrs: { index: "explain" } }, [
_vm._v("说明")
])
],
2
)
],
1
)
],
1
),
_vm._v(" "),
_c(
"el-col",
{
staticStyle: { height: "100%", overflow: "auto" },
attrs: { span: 21 }
},
[_c("keep-alive", [_c("router-view")], 1)],
1
)
],
1
)
],
1
)
}
var staticRenderFns = []
render._withStripped = true
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);
if (true) {
module.hot.accept()
if (module.hot.data) {
__webpack_require__(3) .rerender("data-v-3b7df5a6", esExports)
}
}
/***/ }),
/***/ 31:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_bustCache_manage_vue__ = __webpack_require__(132);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3b7df5a6_hasScoped_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_bustCache_manage_vue__ = __webpack_require__(133);
var disposed = false
function injectStyle (ssrContext) {
if (disposed) return
__webpack_require__(131)
}
var normalizeComponent = __webpack_require__(7)
/* script */
/* template */
/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = null
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_bustCache_manage_vue__["a" /* default */],
__WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_3b7df5a6_hasScoped_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_bustCache_manage_vue__["a" /* default */],
__vue_template_functional__,
__vue_styles__,
__vue_scopeId__,
__vue_module_identifier__
)
Component.options.__file = "src\\page\\manage.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) { return key !== "default" && key.substr(0, 2) !== "__"})) { console.error("named exports are not supported in *.vue files.")}
/* hot reload */
if (true) {(function () {
var hotAPI = __webpack_require__(3)
hotAPI.install(__webpack_require__(0), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-3b7df5a6", Component.options)
} else {
hotAPI.reload("data-v-3b7df5a6", Component.options)
' + ' }
module.hot.dispose(function (data) {
disposed = true
})
})()}
/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
/***/ })
});
//# sourceMappingURL=4.bundle.js.map

View File

@ -1,308 +0,0 @@
webpackJsonp([5],{
/***/ 116:
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(4)(true);
// imports
// module
exports.push([module.i, "\n.allcover[data-v-01efbc38] {\n position: absolute;\n top: 0;\n right: 0;\n}\n.ctt[data-v-01efbc38] {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.tb[data-v-01efbc38] {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n.lr[data-v-01efbc38] {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n.login_page[data-v-01efbc38] {\n background-color: #324057;\n}\n.manage_tip[data-v-01efbc38] {\n position: absolute;\n width: 100%;\n top: -100px;\n left: 0;\n}\n.manage_tip p[data-v-01efbc38] {\n font-size: 34px;\n color: #fff;\n}\n.form_contianer[data-v-01efbc38] {\n width: 320px;\n height: 210px;\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -105px;\n margin-left: -160px;\n padding: 25px;\n border-radius: 5px;\n text-align: center;\n background-color: #fff;\n}\n.form_contianer .submit_btn[data-v-01efbc38] {\n width: 100%;\n font-size: 16px;\n}\n.tip[data-v-01efbc38] {\n font-size: 12px;\n color: red;\n}\n.form-fade-enter-active[data-v-01efbc38],\n.form-fade-leave-active[data-v-01efbc38] {\n transition: all 1s;\n}\n.form-fade-enter[data-v-01efbc38],\n.form-fade-leave-active[data-v-01efbc38] {\n transform: translate3d(0, -50px, 0);\n opacity: 0;\n}\n", "", {"version":3,"sources":["E:/parent/happylifeplat-tcc/happylifeplat-tcc-dashboard/src/page/login.vue"],"names":[],"mappings":";AAAA;EACE,mBAAmB;EACnB,OAAO;EACP,SAAS;CACV;AACD;EACE,mBAAmB;EACnB,SAAS;EACT,UAAU;EACV,iCAAiC;CAClC;AACD;EACE,mBAAmB;EACnB,SAAS;EACT,4BAA4B;CAC7B;AACD;EACE,mBAAmB;EACnB,UAAU;EACV,4BAA4B;CAC7B;AACD;EACE,0BAA0B;CAC3B;AACD;EACE,mBAAmB;EACnB,YAAY;EACZ,YAAY;EACZ,QAAQ;CACT;AACD;EACE,gBAAgB;EAChB,YAAY;CACb;AACD;EACE,aAAa;EACb,cAAc;EACd,mBAAmB;EACnB,SAAS;EACT,UAAU;EACV,mBAAmB;EACnB,oBAAoB;EACpB,cAAc;EACd,mBAAmB;EACnB,mBAAmB;EACnB,uBAAuB;CACxB;AACD;EACE,YAAY;EACZ,gBAAgB;CACjB;AACD;EACE,gBAAgB;EAChB,WAAW;CACZ;AACD;;EAEE,mBAAmB;CACpB;AACD;;EAEE,oCAAoC;EACpC,WAAW;CACZ","file":"login.vue","sourcesContent":[".allcover {\n position: absolute;\n top: 0;\n right: 0;\n}\n.ctt {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.tb {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n.lr {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n.login_page {\n background-color: #324057;\n}\n.manage_tip {\n position: absolute;\n width: 100%;\n top: -100px;\n left: 0;\n}\n.manage_tip p {\n font-size: 34px;\n color: #fff;\n}\n.form_contianer {\n width: 320px;\n height: 210px;\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -105px;\n margin-left: -160px;\n padding: 25px;\n border-radius: 5px;\n text-align: center;\n background-color: #fff;\n}\n.form_contianer .submit_btn {\n width: 100%;\n font-size: 16px;\n}\n.tip {\n font-size: 12px;\n color: red;\n}\n.form-fade-enter-active,\n.form-fade-leave-active {\n transition: all 1s;\n}\n.form-fade-enter,\n.form-fade-leave-active {\n transform: translate3d(0, -50px, 0);\n opacity: 0;\n}\n"],"sourceRoot":""}]);
// exports
/***/ }),
/***/ 128:
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(116);
if(typeof content === 'string') content = [[module.i, content, '']];
if(content.locals) module.exports = content.locals;
// add the styles to the DOM
var update = __webpack_require__(8)("21364a1d", content, false);
// Hot Module Replacement
if(true) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept(116, function() {
var newContent = __webpack_require__(116);
if(typeof newContent === 'string') newContent = [[module.i, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/***/ 129:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["a"] = ({
data: function data() {
return {
loginForm: {
username: '',
password: ''
},
rules: {
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
},
showLogin: false,
baseUrl: document.getElementById('serverIpAddress').href
};
},
mounted: function mounted() {
this.showLogin = true;
},
computed: {},
methods: {
submitForm: function submitForm() {
var _this = this;
this.$http.post(this.baseUrl + '/login', {
userName: this.loginForm.username,
password: this.loginForm.password
}).then(function (response) {
if (response.body.data == true) {
_this.$message({
type: 'success',
message: '登录成功'
});
_this.$router.push('manage');
} else if (response.body.data == false) {
_this.$message({
type: 'error',
message: '请输入正确的用户名密码'
});
}
console.log("success!");
}, function (response) {
_this.$message({
type: 'error',
message: response
});
});
}
},
watch: {}
});
/***/ }),
/***/ 130:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ staticClass: "login_page fillcontain" },
[
_c("transition", { attrs: { name: "form-fade", mode: "in-out" } }, [
_c(
"section",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.showLogin,
expression: "showLogin"
}
],
staticClass: "form_contianer"
},
[
_c("div", { staticClass: "manage_tip" }, [
_c("p", [_vm._v("Tcc-Admin")])
]),
_vm._v(" "),
_c(
"el-form",
{
ref: "loginForm",
attrs: { model: _vm.loginForm, rules: _vm.rules }
},
[
_c(
"el-form-item",
{ attrs: { prop: "username" } },
[
_c(
"el-input",
{
attrs: { placeholder: "用户名" },
model: {
value: _vm.loginForm.username,
callback: function($$v) {
_vm.$set(_vm.loginForm, "username", $$v)
},
expression: "loginForm.username"
}
},
[_c("span", [_vm._v("dsfsf")])]
)
],
1
),
_vm._v(" "),
_c(
"el-form-item",
{ attrs: { prop: "password" } },
[
_c("el-input", {
attrs: { type: "password", placeholder: "密码" },
model: {
value: _vm.loginForm.password,
callback: function($$v) {
_vm.$set(_vm.loginForm, "password", $$v)
},
expression: "loginForm.password"
}
})
],
1
),
_vm._v(" "),
_c(
"el-form-item",
[
_c(
"el-button",
{
staticClass: "submit_btn",
attrs: { type: "primary" },
on: {
click: function($event) {
_vm.submitForm("loginForm")
}
}
},
[_vm._v("登录")]
)
],
1
)
],
1
)
],
1
)
])
],
1
)
}
var staticRenderFns = []
render._withStripped = true
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);
if (true) {
module.hot.accept()
if (module.hot.data) {
__webpack_require__(3) .rerender("data-v-01efbc38", esExports)
}
}
/***/ }),
/***/ 30:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_bustCache_login_vue__ = __webpack_require__(129);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_01efbc38_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_bustCache_login_vue__ = __webpack_require__(130);
var disposed = false
function injectStyle (ssrContext) {
if (disposed) return
__webpack_require__(128)
}
var normalizeComponent = __webpack_require__(7)
/* script */
/* template */
/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-01efbc38"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_bustCache_login_vue__["a" /* default */],
__WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_01efbc38_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_bustCache_login_vue__["a" /* default */],
__vue_template_functional__,
__vue_styles__,
__vue_scopeId__,
__vue_module_identifier__
)
Component.options.__file = "src\\page\\login.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) { return key !== "default" && key.substr(0, 2) !== "__"})) { console.error("named exports are not supported in *.vue files.")}
/* hot reload */
if (true) {(function () {
var hotAPI = __webpack_require__(3)
hotAPI.install(__webpack_require__(0), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-01efbc38", Component.options)
} else {
hotAPI.reload("data-v-01efbc38", Component.options)
' + ' }
module.hot.dispose(function (data) {
disposed = true
})
})()}
/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
/***/ })
});
//# sourceMappingURL=5.bundle.js.map

View File

@ -1,308 +0,0 @@
webpackJsonp([6],{
/***/ 117:
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(4)(true);
// imports
// module
exports.push([module.i, "\n.allcover[data-v-5eb4c56e] {\n position: absolute;\n top: 0;\n right: 0;\n}\n.ctt[data-v-5eb4c56e] {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.tb[data-v-5eb4c56e] {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n.lr[data-v-5eb4c56e] {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n.login_page[data-v-5eb4c56e] {\n background-color: #324057;\n}\n.manage_tip[data-v-5eb4c56e] {\n position: absolute;\n width: 100%;\n top: -100px;\n left: 0;\n}\n.manage_tip p[data-v-5eb4c56e] {\n font-size: 34px;\n color: #fff;\n}\n.form_contianer[data-v-5eb4c56e] {\n width: 320px;\n height: 210px;\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -105px;\n margin-left: -160px;\n padding: 25px;\n border-radius: 5px;\n text-align: center;\n background-color: #fff;\n}\n.form_contianer .submit_btn[data-v-5eb4c56e] {\n width: 100%;\n font-size: 16px;\n}\n.tip[data-v-5eb4c56e] {\n font-size: 12px;\n color: red;\n}\n.form-fade-enter-active[data-v-5eb4c56e],\n.form-fade-leave-active[data-v-5eb4c56e] {\n transition: all 1s;\n}\n.form-fade-enter[data-v-5eb4c56e],\n.form-fade-leave-active[data-v-5eb4c56e] {\n transform: translate3d(0, -50px, 0);\n opacity: 0;\n}\n", "", {"version":3,"sources":["E:/parent/happylifeplat-transaction/happylifeplat-transaction-dashboard/src/page/login.vue"],"names":[],"mappings":";AAAA;EACE,mBAAmB;EACnB,OAAO;EACP,SAAS;CACV;AACD;EACE,mBAAmB;EACnB,SAAS;EACT,UAAU;EACV,iCAAiC;CAClC;AACD;EACE,mBAAmB;EACnB,SAAS;EACT,4BAA4B;CAC7B;AACD;EACE,mBAAmB;EACnB,UAAU;EACV,4BAA4B;CAC7B;AACD;EACE,0BAA0B;CAC3B;AACD;EACE,mBAAmB;EACnB,YAAY;EACZ,YAAY;EACZ,QAAQ;CACT;AACD;EACE,gBAAgB;EAChB,YAAY;CACb;AACD;EACE,aAAa;EACb,cAAc;EACd,mBAAmB;EACnB,SAAS;EACT,UAAU;EACV,mBAAmB;EACnB,oBAAoB;EACpB,cAAc;EACd,mBAAmB;EACnB,mBAAmB;EACnB,uBAAuB;CACxB;AACD;EACE,YAAY;EACZ,gBAAgB;CACjB;AACD;EACE,gBAAgB;EAChB,WAAW;CACZ;AACD;;EAEE,mBAAmB;CACpB;AACD;;EAEE,oCAAoC;EACpC,WAAW;CACZ","file":"login.vue","sourcesContent":[".allcover {\n position: absolute;\n top: 0;\n right: 0;\n}\n.ctt {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.tb {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n.lr {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n.login_page {\n background-color: #324057;\n}\n.manage_tip {\n position: absolute;\n width: 100%;\n top: -100px;\n left: 0;\n}\n.manage_tip p {\n font-size: 34px;\n color: #fff;\n}\n.form_contianer {\n width: 320px;\n height: 210px;\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -105px;\n margin-left: -160px;\n padding: 25px;\n border-radius: 5px;\n text-align: center;\n background-color: #fff;\n}\n.form_contianer .submit_btn {\n width: 100%;\n font-size: 16px;\n}\n.tip {\n font-size: 12px;\n color: red;\n}\n.form-fade-enter-active,\n.form-fade-leave-active {\n transition: all 1s;\n}\n.form-fade-enter,\n.form-fade-leave-active {\n transform: translate3d(0, -50px, 0);\n opacity: 0;\n}\n"],"sourceRoot":""}]);
// exports
/***/ }),
/***/ 130:
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(117);
if(typeof content === 'string') content = [[module.i, content, '']];
if(content.locals) module.exports = content.locals;
// add the styles to the DOM
var update = __webpack_require__(8)("3bca7a7c", content, false);
// Hot Module Replacement
if(true) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept(117, function() {
var newContent = __webpack_require__(117);
if(typeof newContent === 'string') newContent = [[module.i, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/***/ 131:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["a"] = ({
data: function data() {
return {
loginForm: {
username: '',
password: ''
},
rules: {
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
},
showLogin: false,
baseUrl: document.getElementById('serverIpAddress').href
};
},
mounted: function mounted() {
this.showLogin = true;
},
computed: {},
methods: {
submitForm: function submitForm() {
var _this = this;
this.$http.post(this.baseUrl + '/login', {
userName: this.loginForm.username,
password: this.loginForm.password
}).then(function (response) {
if (response.body.data == true) {
_this.$message({
type: 'success',
message: '登录成功'
});
_this.$router.push('manage');
} else if (response.body.data == false) {
_this.$message({
type: 'error',
message: '请输入正确的用户名密码'
});
}
console.log("success!");
}, function (response) {
_this.$message({
type: 'error',
message: response
});
});
}
},
watch: {}
});
/***/ }),
/***/ 132:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ staticClass: "login_page fillcontain" },
[
_c("transition", { attrs: { name: "form-fade", mode: "in-out" } }, [
_c(
"section",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.showLogin,
expression: "showLogin"
}
],
staticClass: "form_contianer"
},
[
_c("div", { staticClass: "manage_tip" }, [
_c("p", [_vm._v("Transaction Admin")])
]),
_vm._v(" "),
_c(
"el-form",
{
ref: "loginForm",
attrs: { model: _vm.loginForm, rules: _vm.rules }
},
[
_c(
"el-form-item",
{ attrs: { prop: "username" } },
[
_c(
"el-input",
{
attrs: { placeholder: "用户名" },
model: {
value: _vm.loginForm.username,
callback: function($$v) {
_vm.$set(_vm.loginForm, "username", $$v)
},
expression: "loginForm.username"
}
},
[_c("span", [_vm._v("dsfsf")])]
)
],
1
),
_vm._v(" "),
_c(
"el-form-item",
{ attrs: { prop: "password" } },
[
_c("el-input", {
attrs: { type: "password", placeholder: "密码" },
model: {
value: _vm.loginForm.password,
callback: function($$v) {
_vm.$set(_vm.loginForm, "password", $$v)
},
expression: "loginForm.password"
}
})
],
1
),
_vm._v(" "),
_c(
"el-form-item",
[
_c(
"el-button",
{
staticClass: "submit_btn",
attrs: { type: "primary" },
on: {
click: function($event) {
_vm.submitForm("loginForm")
}
}
},
[_vm._v("登录")]
)
],
1
)
],
1
)
],
1
)
])
],
1
)
}
var staticRenderFns = []
render._withStripped = true
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);
if (true) {
module.hot.accept()
if (module.hot.data) {
__webpack_require__(3) .rerender("data-v-5eb4c56e", esExports)
}
}
/***/ }),
/***/ 30:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_bustCache_login_vue__ = __webpack_require__(131);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_5eb4c56e_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_bustCache_login_vue__ = __webpack_require__(132);
var disposed = false
function injectStyle (ssrContext) {
if (disposed) return
__webpack_require__(130)
}
var normalizeComponent = __webpack_require__(7)
/* script */
/* template */
/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-5eb4c56e"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_bustCache_login_vue__["a" /* default */],
__WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_5eb4c56e_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_bustCache_login_vue__["a" /* default */],
__vue_template_functional__,
__vue_styles__,
__vue_scopeId__,
__vue_module_identifier__
)
Component.options.__file = "src\\page\\login.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) { return key !== "default" && key.substr(0, 2) !== "__"})) { console.error("named exports are not supported in *.vue files.")}
/* hot reload */
if (true) {(function () {
var hotAPI = __webpack_require__(3)
hotAPI.install(__webpack_require__(0), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-5eb4c56e", Component.options)
} else {
hotAPI.reload("data-v-5eb4c56e", Component.options)
' + ' }
module.hot.dispose(function (data) {
disposed = true
})
})()}
/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
/***/ })
});
//# sourceMappingURL=6.bundle.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,13 +0,0 @@
<html>
<head>
<meta charset="utf-8">
<title>manage-dev</title>
</head>
<body>
<div id="app">
<app></app>
</div>
<a id="serverIpAddress" style="display: none" href="http://localhost:8888/hmily-admin">
</a>
<script type="text/javascript" src="bundle.js"></script></body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

View File

@ -1,70 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p>Description:</p>
*
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/20 16:01
* @since JDK 1.8
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class JdbcCompensationServiceImplTest {
/** logger */
private static final Logger LOGGER = LoggerFactory.getLogger(JdbcCompensationServiceImplTest.class);
@Autowired
private CompensationService compensationService;
@Test
public void listByPage() throws Exception {
CompensationQuery query = new CompensationQuery();
PageParameter pageParameter = new PageParameter(1,10);
query.setPageParameter(pageParameter);
query.setApplicationName("account-service");
final CommonPager<HmilyCompensationVO> pager = compensationService.listByPage(query);
Assert.assertNotNull(pager.getDataList());
}
}

View File

@ -1,65 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p>Description:</p>
*
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/20 16:01
* @since JDK 1.8
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class MongoCompensationServiceImplTest {
@Autowired
private CompensationService compensationService;
@Test
public void listByPage() throws Exception {
CompensationQuery query = new CompensationQuery();
query.setApplicationName("alipay-service");
PageParameter pageParameter = new PageParameter(1,5);
query.setPageParameter(pageParameter);
final CommonPager<HmilyCompensationVO> voCommonPager = compensationService.listByPage(query);
}
}

View File

@ -1,66 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p>Description:</p>
*
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/20 16:01
* @since JDK 1.8
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class RedisCompensationServiceImplTest {
@Autowired
private CompensationService compensationService;
@Test
public void listByPage() throws Exception {
CompensationQuery query = new CompensationQuery();
query.setApplicationName("alipay-service");
PageParameter pageParameter = new PageParameter(1, 1);
query.setPageParameter(pageParameter);
query.setRetry(2);
query.setTransId("2075304338");
final CommonPager<HmilyCompensationVO> voCommonPager = compensationService.listByPage(query);
}
}

View File

@ -1,63 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hmily.admin.service.compensate;
import org.dromara.hmily.admin.page.CommonPager;
import org.dromara.hmily.admin.page.PageParameter;
import org.dromara.hmily.admin.query.CompensationQuery;
import org.dromara.hmily.admin.service.CompensationService;
import org.dromara.hmily.admin.vo.HmilyCompensationVO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p>Description:</p>
*
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/20 16:01
* @since JDK 1.8
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ZookeeperCompensationServiceImplTest {
@Autowired
private CompensationService compensationService;
@Test
public void listByPage() throws Exception {
CompensationQuery query = new CompensationQuery();
query.setApplicationName("alipay-service");
PageParameter pageParameter = new PageParameter(1, 8);
query.setPageParameter(pageParameter);
final CommonPager<HmilyCompensationVO> voCommonPager = compensationService.listByPage(query);
}
}

View File

@ -19,8 +19,6 @@ package org.dromara.hmily.repository.database.manager;
import com.google.common.collect.Maps;
import com.zaxxer.hikari.HikariDataSource;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@ -37,8 +35,6 @@ import java.util.stream.Collectors;
import javax.sql.DataSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.dromara.hmily.common.utils.CollectionUtils;
import org.dromara.hmily.config.HmilyConfig;
import org.dromara.hmily.config.HmilyDbConfig;
@ -561,7 +557,7 @@ public abstract class AbstractHmilyDatabase implements HmilyRepository {
hmilyParticipant.setConfirmMethod((String) map.get("confirm_method"));
hmilyParticipant.setCancelMethod((String) map.get("cancel_method"));
try {
if(Objects.nonNull(map.get("confirm_invocation"))) {
if (Objects.nonNull(map.get("confirm_invocation"))) {
byte[] confirmInvocation = (byte[]) map.get("confirm_invocation");
final HmilyInvocation confirmHmilyInvocation = hmilySerializer.deSerialize(confirmInvocation, HmilyInvocation.class);
hmilyParticipant.setConfirmHmilyInvocation(confirmHmilyInvocation);

11
pom.xml
View File

@ -12,7 +12,6 @@
<module>hmily-common</module>
<module>hmily-core</module>
<module>hmily-annotation</module>
<!-- <module>hmily-admin</module>-->
<module>hmily-spring-boot-starter</module>
<module>hmily-spi</module>
<module>hmily-serializer</module>
@ -38,9 +37,9 @@
</license>
</licenses>
<scm>
<url>https://github.com/yu199195/hmily.git</url>
<connection>scm:git:https://github.com/yu199195/hmily</connection>
<developerConnection>scm:git:git@github.com:yu199195/hmily</developerConnection>
<url>https://github.com/dromara/hmily.git</url>
<connection>scm:git:https://github.com/dromara/hmily</connection>
<developerConnection>scm:git:git@github.com:dromara/hmily</developerConnection>
<tag>${project.version}</tag>
</scm>
@ -52,7 +51,7 @@
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/yu199195/hmily/issues</url>
<url>https://github.com/dromara/hmily/issues</url>
</issueManagement>
<developers>
@ -62,7 +61,7 @@
<email>549477611@qq.com</email>
<organization>dromara.org</organization>
<roles>
<role>Developer</role>
<role>author</role>
</roles>
</developer>
</developers>