Skip to content

Commit

Permalink
1.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cym1102 committed May 27, 2024
1 parent 1fabdca commit 6291ac8
Show file tree
Hide file tree
Showing 9 changed files with 270 additions and 143 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ Windows上倒是有不错的svn服务端软件即VisualSVN, 但一来Windows服
使用docker版则无需安装任何其他软件,使用http:\\\\协议进行checkout。


```
演示地址: http://svn.nginxwebui.cn:6060
用户名: admin
密码: admin
```


#### 安装说明

Expand All @@ -64,8 +58,9 @@ yum install subversion
Windows:

```
下载JDK安装包 https://www.oracle.com/java/technologies/downloads/
下载VisualSVN https://www.visualsvn.com/server/download
下载并安装JDK安装包 https://www.oracle.com/java/technologies/downloads/
下载并安装VisualSVN https://www.visualsvn.com/server/download
在服务管理器中停止并禁用VisualSVN相关服务
配置JAVA环境变量
JAVA_HOME : JDK安装目录
Path : JDK安装目录\bin
Expand All @@ -77,9 +72,9 @@ Path : JDK安装目录\bin

```
Linux: mkdir /home/svnWebUI/
wget -O /home/svnWebUI/svnWebUI.jar http://file.nginxwebui.cn/svnWebUI-1.8.3.jar
wget -O /home/svnWebUI/svnWebUI.jar http://file.nginxwebui.cn/svnWebUI-1.8.4.jar
Windows: 直接使用浏览器下载 http://file.nginxwebui.cn/svnWebUI-1.8.3.jar 到 D:/home/svnWebUI/svnWebUI.jar
Windows: 直接使用浏览器下载 http://file.nginxwebui.cn/svnWebUI-1.8.4.jar 到 D:/home/svnWebUI/svnWebUI.jar
```

有新版本只需要修改路径中的版本即可
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.cym</groupId>
<artifactId>svnWebUI</artifactId>
<version>1.8.3</version>
<version>1.8.4</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/cym/controller/GroupController.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public JsonResult del(String id) {

@Mapping("importOver")
public JsonResult importOver(String dirTemp) {

if (!dirTemp.replace("\\", "/").contains(FileUtil.getTmpDir().getPath().replace("\\", "/"))) {
return renderError("文件路径不合法");
}

List<String> lines = FileUtil.readLines(dirTemp, Charset.forName("UTF-8"));
boolean start = false;
for (String line : lines) {
Expand Down
41 changes: 40 additions & 1 deletion src/main/java/com/cym/controller/RepositoryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ public ModelAndView index(Page page, String keywords) {
repositoryExt.setMark(repositoryExt.getMark().replace("\n", "<br>").replace(" ", "&nbsp;"));
}
}

ModelAndView modelAndView = new ModelAndView("/adminPage/repository/index.html");
modelAndView.put("keywords", keywords);
modelAndView.put("page", pageExt);
modelAndView.put("home", homeConfig.home);
modelAndView.put("repositoryList" ,sqlHelper.findAll(Repository.class));
return modelAndView;
}

Expand All @@ -106,6 +107,9 @@ public JsonResult addOver(String name) {
configService.refresh();
return renderSuccess();
}




@Mapping("detail")
public JsonResult detail(String id) {
Expand Down Expand Up @@ -308,4 +312,39 @@ public JsonResult editMark(String id, String mark) {
return renderSuccess();
}

@Mapping("copyPermissionOver")
public JsonResult copyPermissionOver(String toId, String fromId) {
if(toId.equals(fromId)) {
return renderError("目标仓库与来源仓库相同");
}

repositoryService.copyPermission(toId, fromId);

configService.refresh();
return renderSuccess();
}


@Mapping("copyRepoOver")
public JsonResult copyRepoOver(String copyName, String fromCopyId) {
if (StrUtil.isEmpty(copyName)) {
return renderError("仓库名为空");
}
if (isSpecialChar(copyName)) {
return renderError("名称包含特殊字符");
}
Repository repositoryOrg = repositoryService.getByName(copyName, null);
if (repositoryOrg != null) {
return renderError("此仓库名已存在");
}

if (repositoryService.hasDir(copyName)) {
return renderError("该仓库文件夹已存在, 请使用扫描功能添加");
}

repositoryService.copyRepoOver(copyName, fromCopyId);

configService.refresh();
return renderSuccess();
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/cym/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public JsonResult del(String id) {

@Mapping("importOver")
public JsonResult importOver(String dirTemp) {
if (!dirTemp.replace("\\", "/").contains(FileUtil.getTmpDir().getPath().replace("\\", "/"))) {
return renderError("文件路径不合法");
}

List<String> lines = FileUtil.readLines(dirTemp, Charset.forName("UTF-8"));
for (String line : lines) {
Expand Down
54 changes: 49 additions & 5 deletions src/main/java/com/cym/service/RepositoryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -46,7 +47,7 @@ public Page search(Page page, String keywords) {
ConditionAndWrapper conditionAndWrapper = new ConditionAndWrapper();

if (StrUtil.isNotEmpty(keywords)) {
String trimKeywords = CharSequenceUtil.trim(keywords,0);
String trimKeywords = CharSequenceUtil.trim(keywords, 0);
conditionAndWrapper.and(new ConditionOrWrapper().like(Repository::getName, trimKeywords));
}

Expand Down Expand Up @@ -82,17 +83,34 @@ public void insertOrUpdate(String name) {
if (!FileUtil.exist(dir + File.separator + "db")) {
ClassPathResource resource = new ClassPathResource("file/repo.zip");
InputStream inputStream = resource.getStream();
File temp = new File(homeConfig.home + "temp" + File.separator + "repo.zip");
FileUtil.writeFromStream(inputStream, temp);
// File temp = new File(homeConfig.home + "temp" + File.separator + "repo.zip");
// FileUtil.writeFromStream(inputStream, temp);
FileUtil.mkdir(dir);
ZipUtil.unzip(temp, new File(dir));
FileUtil.del(temp);
ZipUtil.unzip(inputStream, new File(dir), StandardCharsets.UTF_8);
// FileUtil.del(temp);
}

Repository repository = new Repository();
repository.setName(name);
sqlHelper.insertOrUpdate(repository);
}


public void copyRepoOver(String copyName, String fromCopyId) {
// 复制仓库
Repository repositoryFrom = sqlHelper.findById(fromCopyId, Repository.class);
String fromDir = homeConfig.home + "repo" + File.separator + repositoryFrom.getName();

String toDir = homeConfig.home + "repo" + File.separator + copyName;

FileUtil.copyContent(new File(fromDir), new File(toDir), true);

Repository repository = new Repository();
repository.setName(copyName);
sqlHelper.insertOrUpdate(repository);
}



public List<UserExt> getUserExts(String id) {
List<RepositoryUser> repositoryUsers = sqlHelper.findListByQuery(new ConditionAndWrapper().ne(RepositoryUser::getPermission, "n").eq(RepositoryUser::getRepositoryId, id),
Expand Down Expand Up @@ -323,4 +341,30 @@ public List<Repository> getListByAllPermission() {
return sqlHelper.findListByQuery(new ConditionOrWrapper().eq(Repository::getAllPermission, "r").eq(Repository::getAllPermission, "rw"), Repository.class);
}

public void copyPermission(String toId, String fromId) {
Repository repositoryFrom = sqlHelper.findById(fromId, Repository.class);
Repository repositoryTo = sqlHelper.findById(toId, Repository.class);

// 删除目标权限
sqlHelper.deleteByQuery(new ConditionAndWrapper().eq(RepositoryGroup::getRepositoryId, toId), RepositoryGroup.class);
sqlHelper.deleteByQuery(new ConditionAndWrapper().eq(RepositoryUser::getRepositoryId, toId), RepositoryUser.class);
// 全局权限
repositoryTo.setAllPermission(repositoryFrom.getAllPermission());
sqlHelper.updateById(repositoryTo);

// 插入其他权限
List<RepositoryGroup> repositoryGroups = sqlHelper.findListByQuery(new ConditionAndWrapper().eq(RepositoryGroup::getRepositoryId, fromId), RepositoryGroup.class);
for (RepositoryGroup repositoryGroup : repositoryGroups) {
repositoryGroup.setRepositoryId(toId);
sqlHelper.insert(repositoryGroup);
}

List<RepositoryUser> repositoryUsers = sqlHelper.findListByQuery(new ConditionAndWrapper().eq(RepositoryUser::getRepositoryId, fromId), RepositoryUser.class);
for (RepositoryUser repositoryUser : repositoryUsers) {
repositoryUser.setRepositoryId(toId);
sqlHelper.insert(repositoryUser);
}

}

}
4 changes: 2 additions & 2 deletions src/main/resources/WEB-INF/view/adminPage/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<form id="loginForm">
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
<div class="layui-input-inline">
<input type="text" name="name" id="name" class="layui-input" value="">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<div class="layui-input-inline">
<input type="password" name="pass" id="pass" class="layui-input" value="" onkeyup="getKey()">
</div>
</div>
Expand Down
Loading

0 comments on commit 6291ac8

Please sign in to comment.