Skip to content

Commit

Permalink
feature: Implementation of front-end page of globalsession query inte…
Browse files Browse the repository at this point in the history
…rface (apache#4435)
  • Loading branch information
liuqiufeng committed Mar 11, 2022
1 parent ea0607b commit dec8dcb
Show file tree
Hide file tree
Showing 61 changed files with 1,614 additions and 407 deletions.
1 change: 1 addition & 0 deletions changes/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#4335](https://github.com/seata/seata/pull/4335)] 实现配置中心上传配置交互脚本(nacos,etcd3)
- [[#4332](https://github.com/seata/seata/pull/4332)] 实现配置中心上传配置交互脚本(apollo,consul,zk)
- [[#4320](https://github.com/seata/seata/pull/4320)] 实现控制台db模式全局事务、锁查询接口
- [[#4435](https://github.com/seata/seata/pull/4435)] 控制台前端页面实现


### bugfix:
Expand Down
1 change: 1 addition & 0 deletions changes/en-us/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [[#4335](https://github.com/seata/seata/pull/4335)] Realize configuration center upload configuration interactive script (nacos,etcd3)
- [[#4332](https://github.com/seata/seata/pull/4332)] Realize configuration center upload configuration interactive script (apollo,consul,zk)
- [[#4320](https://github.com/seata/seata/pull/4320)] realize the interface of console: get global session and global lock in the db mode
- [[#4435](https://github.com/seata/seata/pull/4435)] console front-end page implementation

### bugfix:
- [[#3497](https://github.com/seata/seata/pull/3497)] fix tcc phase two response timeout exception
Expand Down
49 changes: 49 additions & 0 deletions console/src/main/java/io/seata/console/config/JacksonConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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 io.seata.console.config;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @author liuqiufeng
*/
@Configuration(proxyBeanMethods = false)
public class JacksonConfig {

/**
* convert long to string for return to the front end
*/
@Bean
public Jackson2ObjectMapperBuilderCustomizer longToStringCustomizer() {
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.serializerByType(Long.class, new JsonSerializer<Long>() {
@Override
public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
if (value == null) {
jsonGenerator.writeString("");
} else {
jsonGenerator.writeString(value.toString());
}
}
});
}
}
18 changes: 9 additions & 9 deletions console/src/main/java/io/seata/console/constant/Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ public enum Code {
/**
* response success
*/
SUCCESS(200, "ok"),
SUCCESS("200", "ok"),
/**
* server error
*/
ERROR(500, "Server error"),
ERROR("500", "Server error"),
/**
* the custom error
*/
LOGIN_FAILED(401, "Login failed");
LOGIN_FAILED("401", "Login failed");

/**
* The Code.
*/
public int code;
public String code;

/**
* The Msg.
*/
public String msg;

private Code(int code, String msg) {
private Code(String code, String msg) {
this.code = code;
this.msg = msg;
}
Expand All @@ -54,7 +54,7 @@ private Code(int code, String msg) {
*
* @return the code
*/
public int getCode() {
public String getCode() {
return this.code;
}

Expand All @@ -63,7 +63,7 @@ public int getCode() {
*
* @param code the code
*/
public void setCode(int code) {
public void setCode(String code) {
this.code = code;
}

Expand Down Expand Up @@ -91,10 +91,10 @@ public void setMsg(String msg) {
* @param code the code
* @return the error msg
*/
public static String getErrorMsg(int code) {
public static String getErrorMsg(String code) {
Code[] errorCodes = values();
for (Code errCode : errorCodes) {
if (errCode.getCode() == code) {
if (errCode.getCode().equals(code)) {
return errCode.getMsg();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import io.seata.console.config.WebSecurityConfig;
import io.seata.console.constant.Code;
import io.seata.console.result.SingleResult;
import io.seata.console.security.User;
import io.seata.console.utils.JwtTokenUtils;
import io.seata.console.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class AuthController {
* Seata is in broken states.
*/
@PostMapping("/login")
public Result login(HttpServletResponse response, @RequestBody User user) {
public SingleResult<String> login(HttpServletResponse response, @RequestBody User user) {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(
user.getUsername(), user.getPassword());

Expand All @@ -71,9 +71,9 @@ public Result login(HttpServletResponse response, @RequestBody User user) {
//put token into http header
response.addHeader(WebSecurityConfig.AUTHORIZATION_HEADER, authHeader);

return Result.ofSuccess(authHeader);
return SingleResult.success(authHeader);
} catch (BadCredentialsException authentication) {
return Result.ofError(Code.LOGIN_FAILED);
return SingleResult.failure(Code.LOGIN_FAILED);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.Map;

import io.seata.console.utils.Result;
import io.seata.console.result.SingleResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -40,7 +40,7 @@ public class OverviewController {
* @return the data
*/
@GetMapping(value = "/getData")
public Result<List> getData() {
public SingleResult<List> getData() {
List<Map<String, Object>> result = new ArrayList<>();
int count = 10;
while (count-- > 0) {
Expand All @@ -50,6 +50,6 @@ public Result<List> getData() {
result.add(hashMap);
}

return Result.ofSuccess(result);
return SingleResult.success(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.core.console.param;
package io.seata.console.param;

import java.io.Serializable;
import java.util.Date;

/**
* @description: The base param
Expand All @@ -30,9 +29,9 @@ public class BaseParam implements Serializable {

private int pageSize;

private Date timeStart;
private Long timeStart;

private Date timeEnd;
private Long timeEnd;

public int getPageNum() {
return pageNum;
Expand All @@ -50,19 +49,19 @@ public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}

public Date getTimeStart() {
public Long getTimeStart() {
return timeStart;
}

public void setTimeStart(Date timeStart) {
public void setTimeStart(Long timeStart) {
this.timeStart = timeStart;
}

public Date getTimeEnd() {
public Long getTimeEnd() {
return timeEnd;
}

public void setTimeEnd(Date timeEnd) {
public void setTimeEnd(Long timeEnd) {
this.timeEnd = timeEnd;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.core.console.result;
package io.seata.console.result;

import java.io.Serializable;
import java.util.List;

import io.seata.common.exception.FrameworkErrorCode;
import io.seata.core.console.param.BaseParam;
import io.seata.console.param.BaseParam;
/**
* The page result
*
Expand Down Expand Up @@ -104,10 +103,6 @@ public static <T> PageResult<T> failure(String code, String msg) {
return new PageResult<>(code, msg);
}

public static <T> PageResult<T> failure(FrameworkErrorCode errorCode) {
return new PageResult<>(errorCode.getErrCode(), errorCode.getErrMessage());
}

public static <T> PageResult<T> success() {
return new PageResult<>(SUCCESS_CODE, SUCCESS_MSG);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.core.console.result;
package io.seata.console.result;

import java.io.Serializable;

Expand All @@ -39,7 +39,7 @@ public Result(String code, String message) {
}

public boolean isSuccess() {
return SUCCESS_CODE == this.code;
return SUCCESS_CODE.equals(this.code);
}

public String getCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.core.console.result;

import io.seata.common.exception.FrameworkErrorCode;
package io.seata.console.result;

import java.io.Serializable;

import io.seata.console.constant.Code;

/**
* The single result
* @author: zhongxiang.wang
Expand All @@ -44,8 +44,8 @@ public static <T> SingleResult<T> failure(String code, String msg) {
return new SingleResult<>(code, msg);
}

public static <T> SingleResult<T> failure(FrameworkErrorCode errorCode) {
return new SingleResult(errorCode.getErrCode(), errorCode.getErrMessage());
public static <T> SingleResult<T> failure(Code errorCode) {
return new SingleResult(errorCode.getCode(), errorCode.getMsg());
}

public static <T> SingleResult<T> success(T data) {
Expand Down
Loading

0 comments on commit dec8dcb

Please sign in to comment.