Skip to content

Commit

Permalink
doc: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
huifer committed Oct 19, 2020
1 parent 96460ff commit e5eee0e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ mvn clean install
```

- 在启动类上添加`@EnableViewRedisServlet`
- 设置账号密码, 默认账号密码: **redis-admin\redis-admin**
- 设置账号密码, 默认账号密码: **redis-admin\redis-admin**,配置信息如下

```
view:
redis:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public class Beans {
private ApplicationContext context;

@Bean
public ServletRegistrationBean statViewServletRegistrationBean() {
public ServletRegistrationBean viewRedisServlet() {
ServletRegistrationBean<Servlet> servletServletRegistrationBean = new ServletRegistrationBean<>();
servletServletRegistrationBean.setServlet(new ViewRedisServlet("/support/"));
Map<String, String> initParams = new HashMap<>(10);
ViewRedisConfig bean = context.getBean(ViewRedisConfig.class);


if (bean != null) {
if (bean != null && !bean.equals(new ViewRedisConfig())) {

initParams.put(LOGIN_NAME_PARAM, bean.getLoginName());
initParams.put(PASSWORD_PARAM, bean.getPassword());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package com.github.huifer.view.redis.servlet;

import java.util.Objects;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "view.redis")
Expand All @@ -34,6 +36,24 @@ public void setLoginName(String loginName) {
this.loginName = loginName;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ViewRedisConfig that = (ViewRedisConfig) o;
return Objects.equals(loginName, that.loginName) &&
Objects.equals(password, that.password);
}

@Override
public int hashCode() {
return Objects.hash(loginName, password);
}

public String getPassword() {
return password;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.github.huifer.view.redis.servlet.service.impl.SetKeyServiceImpl;
import com.github.huifer.view.redis.servlet.service.impl.StringKeyServiceImpl;
import com.github.huifer.view.redis.servlet.service.impl.ZSetKeyServiceImpl;
import com.github.huifer.view.redis.servlet.utils.Utils;
import com.github.huifer.view.redis.servlet.utils.MyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -102,7 +102,7 @@ protected void returnResourceFile(

}

String text = Utils.readFromResource(filePath);
String text = MyUtils.readFromResource(filePath);
assert text != null;
resp.getWriter().write(text);

Expand Down Expand Up @@ -141,12 +141,12 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws

// 进入登录页面
if ("".equals(path) || "login".equals(path) || "/".equals(path)) {
returnResourceFile("/login.html", "", resp);
returnResourceFile("login.html", "", resp);
}
// 进入 view redis 管理页面
if ("/index.html".equals(path)) {
if (checkSession(req, resp)) {
returnResourceFile("/index.html", "", resp);
returnResourceFile("index.html", "", resp);
}
else {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.nio.charset.StandardCharsets;


public class Utils {
public class MyUtils {

public final static int DEFAULT_BUFFER_SIZE = 1024 * 4;

Expand Down Expand Up @@ -59,14 +59,14 @@ public static String readFromResource(String resource) {
try {
in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
if (in == null) {
in = Utils.class.getResourceAsStream(resource);
in = MyUtils.class.getResourceAsStream(resource);
}

if (in == null) {
return null;
}

String text = Utils.read(in);
String text = MyUtils.read(in);
return text;
}
finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
{
"name": "view.redis.login_name",
"type": "java.lang.String",
"description": "登录的账号",
"defaultValue": "redis-admin",
"sourceType": "com.github.huifer.view.redis.servlet.ViewRedisConfig"
},
{
"name": "view.redis.password",
"type": "java.lang.String",
"defaultValue": "redis-admin",
"description": "登录的密码",
"sourceType": "com.github.huifer.view.redis.servlet.ViewRedisConfig"
}
]
Expand Down

0 comments on commit e5eee0e

Please sign in to comment.