Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 46fe92e

Browse files
committed
change allrepos view
1 parent fd75fca commit 46fe92e

11 files changed

Lines changed: 196 additions & 312 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.gitmining.bean;
22

33
public enum Sort {
4-
GENERAL,STAR,FORK;
4+
GENERAL,STAR,FORK,CONTRIBUTOR;
55
}

src/main/java/org/gitmining/controller/OverviewController.java

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import javax.servlet.http.HttpServletRequest;
1111
import javax.servlet.http.HttpServletResponse;
1212

13+
import org.gitmining.bean.Repository;
1314
import org.gitmining.bean.SimpleRepo;
1415
import org.gitmining.bean.Sort;
1516
import org.gitmining.bean.Tag;
@@ -59,7 +60,7 @@ public ModelAndView getReposView(HttpServletRequest request)
5960
return new ModelAndView("allrepos", "result", result);
6061
}
6162

62-
@RequestMapping(value = "/repos/general", method = RequestMethod.POST)
63+
@RequestMapping(value = "/repos/sort", method = RequestMethod.POST)
6364
public Map getGeneralRepos(HttpServletRequest request,
6465
HttpServletResponse response) throws Exception {
6566
// TODO Auto-generated method stub
@@ -74,62 +75,33 @@ public Map getGeneralRepos(HttpServletRequest request,
7475
System.out.println(tagName[i]);
7576
}
7677

77-
List<SimpleRepo> repos = repoByTagDataService
78-
.searchAndSortByTagPagination(tagNameList, Sort.GENERAL,
79-
currentPage, itemsperPage);
80-
int totalCount = repoByTagDataService.resultCount(tagNameList,
81-
Sort.GENERAL);
82-
result.put("count", totalCount);
83-
result.put("repos", repos);
84-
result.put("count", totalCount);
85-
return result;
86-
}
87-
88-
@RequestMapping(value = "/repos/star", method = RequestMethod.POST)
89-
public Map getStarRepos(HttpServletRequest request,
90-
HttpServletResponse response) throws Exception {
91-
// TODO Auto-generated method stub
92-
Map<String, Object> result = new HashMap<String, Object>();
93-
int currentPage = Integer.parseInt(request.getParameter("pageIndex"));
94-
int itemsperPage = Integer.parseInt(request.getParameter("pageSize"));
95-
96-
String temp = request.getParameter("tag");
97-
String[] tagName = temp.split("ae");
98-
List<String> tagNameList = new ArrayList<String>();
99-
for (int i = 0; i < tagName.length; i++) {
100-
tagNameList.add(tagName[i]);
78+
int type = Integer.parseInt(request.getParameter("type"));
79+
List<Repository> repos = new ArrayList<Repository>();
80+
switch (type) {
81+
case 1:
82+
repos = repoByTagDataService.searchAndSortByTagPagination(
83+
tagNameList, Sort.GENERAL, currentPage, itemsperPage);
84+
break;
85+
case 2:
86+
repos = repoByTagDataService.searchAndSortByTagPagination(
87+
tagNameList, Sort.STAR, currentPage, itemsperPage);
88+
break;
89+
case 3:
90+
repos = repoByTagDataService.searchAndSortByTagPagination(
91+
tagNameList, Sort.FORK, currentPage, itemsperPage);
92+
break;
93+
case 4:
94+
repos = repoByTagDataService.searchAndSortByTagPagination(
95+
tagNameList, Sort.CONTRIBUTOR, currentPage, itemsperPage);
96+
break;
97+
default:
98+
break;
10199
}
102100

103-
List<SimpleRepo> repos = repoByTagDataService
104-
.searchAndSortByTagPagination(tagNameList, Sort.STAR,
105-
currentPage, itemsperPage);
106-
result.put("repos", repos);
107101
int totalCount = repoByTagDataService.resultCount(tagNameList,
108-
Sort.STAR);
102+
Sort.GENERAL);
109103
result.put("count", totalCount);
110-
return result;
111-
}
112-
113-
@RequestMapping(value = "/repos/fork", method = RequestMethod.POST)
114-
public Map getForkRepos(HttpServletRequest request,
115-
HttpServletResponse response) throws Exception {
116-
// TODO Auto-generated method stub
117-
Map<String, Object> result = new HashMap<String, Object>();
118-
int currentPage = Integer.parseInt(request.getParameter("pageIndex"));
119-
int itemsperPage = Integer.parseInt(request.getParameter("pageSize"));
120-
121-
String temp = request.getParameter("tag");
122-
String[] tagName = temp.split("ae");
123-
List<String> tagNameList = new ArrayList<String>();
124-
for (int i = 0; i < tagName.length; i++) {
125-
tagNameList.add(tagName[i]);
126-
}
127-
128-
List<SimpleRepo> repos = repoByTagDataService.searchAndSortByTagPagination(
129-
tagNameList, Sort.FORK,currentPage,itemsperPage);
130104
result.put("repos", repos);
131-
int totalCount = repoByTagDataService.resultCount(tagNameList,
132-
Sort.FORK);
133105
result.put("count", totalCount);
134106
return result;
135107
}

src/main/java/org/gitmining/dao/RepositoryDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface RepositoryDao {
3333
public List<SimpleRepo> getSimpleReposByTagNameAndSort(
3434
List<String> tag_name, String type);
3535

36-
public List<SimpleRepo> getSimpleReposByTagNameAndSortPagination(
36+
public List<Repository> getSimpleReposByTagNameAndSortPagination(
3737
List<String> tag_name, Sort type, int begin, int itemsPerPage);
3838

3939
public List<SimpleRepo> getReposSortByHot(List<Integer> tagIDs, int number);

src/main/java/org/gitmining/dao/impl/RepositoryDaoImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public List<Repository> getContributedRepoByUserId(int user_id) {
121121
}
122122

123123
@Override
124-
public List<SimpleRepo> getSimpleReposByTagNameAndSortPagination(
124+
public List<Repository> getSimpleReposByTagNameAndSortPagination(
125125
List<String> tag_name, Sort type, int begin, int itemsPerPage) {
126126
// TODO Auto-generated method stub
127127

@@ -130,16 +130,21 @@ public List<SimpleRepo> getSimpleReposByTagNameAndSortPagination(
130130
map.put("beginItem", begin);
131131
map.put("itemsPerPage", itemsPerPage);
132132

133-
134133
if (type == Sort.GENERAL) {
135134
return sqlSession.selectList(
136135
"repo.getSimpleReposByTagNameSortGeneralPagination", map);
137136
} else if (type == Sort.STAR) {
137+
map.put("type", "stargazers");
138138
return sqlSession.selectList(
139-
"repo.getSimpleReposByTagNameSortStarPagination", map);
140-
} else {
139+
"repo.getSimpleReposByTagNameSortPagination", map);
140+
} else if(type==Sort.FORK){
141+
map.put("type", "fork_num");
142+
return sqlSession.selectList(
143+
"repo.getSimpleReposByTagNameSortPagination", map);
144+
}else {
145+
map.put("type", "contributor");
141146
return sqlSession.selectList(
142-
"repo.getSimpleReposByTagNameSortForkPagination", map);
147+
"repo.getSimpleReposByTagNameSortPagination", map);
143148
}
144149
}
145150

src/main/java/org/gitmining/mapper/repo.xml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,12 @@
201201
</select>
202202

203203
<!-- 综合排序分页 -->
204-
<select id="getSimpleReposByTagNameSortGeneralPagination" resultMap="simpleRepo">
204+
<select id="getSimpleReposByTagNameSortGeneralPagination" resultMap="repository">
205205
SELECT distinct
206206
re.id AS id
207-
,full_name,owner_name,description,update_time,language,stargazers,fork_num
207+
,full_name,description,type,fork,owner_id,owner_type,owner_name,create_time,push_time,update_time,
208+
language,contributor,collaborator,commit,open_issues,closed_issues,open_pull,closed_pull,merged_pull,rejected_pull,
209+
commit,stargazers,subscribers,fork_num
208210
FROM repotest re,repo_tag rt, tag t where re.id = rt.`repo_id` and
209211
rt.`tag_id` = t.`id` and t.`name` in
210212
<foreach collection="name" item="item" index="index" open="("
@@ -214,36 +216,22 @@
214216
limit #{beginItem}, #{itemsPerPage};
215217
</select>
216218

217-
<!-- star排序分页 -->
218-
<select id="getSimpleReposByTagNameSortStarPagination" resultMap="simpleRepo">
219-
SELECT
220-
distinct re.id AS id
221-
,full_name,owner_name,description,update_time,language,stargazers,fork_num
222-
FROM repotest re,repo_tag rt, tag t where re.id = rt.`repo_id` and
223-
rt.`tag_id` = t.`id` and t.`name` in
224-
<foreach collection="name" item="item" index="index" open="("
225-
close=")" separator=",">
226-
#{item}
227-
</foreach>
228-
order by stargazers desc limit #{beginItem}, #{itemsPerPage};
229-
</select>
230-
231-
<!-- fork排序分页 -->
232-
<select id="getSimpleReposByTagNameSortForkPagination" resultMap="simpleRepo">
219+
<!-- type排序分页 -->
220+
<select id="getSimpleReposByTagNameSortPagination" resultMap="repository">
233221
SELECT
234222
distinct re.id AS id
235-
,full_name,owner_name,description,update_time,language,stargazers,fork_num
223+
,full_name,description,type,fork,owner_id,owner_type,owner_name,create_time,push_time,update_time,
224+
language,contributor,collaborator,commit,open_issues,closed_issues,open_pull,closed_pull,merged_pull,rejected_pull,
225+
commit,stargazers,subscribers,fork_num
236226
FROM repotest re,repo_tag rt, tag t where re.id = rt.`repo_id` and
237227
rt.`tag_id` = t.`id` and t.`name` in
238228
<foreach collection="name" item="item" index="index" open="("
239229
close=")" separator=",">
240230
#{item}
241231
</foreach>
242-
order by fork_num
243-
desc limit #{beginItem}, #{itemsPerPage} ;
232+
order by #{type} desc limit #{beginItem}, #{itemsPerPage};
244233
</select>
245234

246-
247235
<!-- top 10 -->
248236
<select id="getReposSortByHot" resultMap="simpleRepo"
249237
parameterType="map">

src/main/java/org/gitmining/service/RepoByTagDataService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.List;
44

5+
import org.gitmining.bean.Repository;
56
import org.gitmining.bean.SimpleRepo;
67
import org.gitmining.bean.Sort;
78
import org.gitmining.bean.Tag;
@@ -11,7 +12,7 @@ public interface RepoByTagDataService {
1112
public List<SimpleRepo> searchAndSortByTag(List<String> tagName, Sort type);
1213

1314
//分页
14-
public List<SimpleRepo> searchAndSortByTagPagination(List<String> tagName,
15+
public List<Repository> searchAndSortByTagPagination(List<String> tagName,
1516
Sort type, int currentPage, int itemsPerPage);
1617

1718
// 结果集总行数

src/main/java/org/gitmining/service/impl/RepoByTagDataServiceImpl.java

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.gitmining.bean.Repository;
67
import org.gitmining.bean.SimpleRepo;
78
import org.gitmining.bean.Sort;
89
import org.gitmining.bean.Tag;
@@ -94,44 +95,28 @@ public List<SimpleRepo> getReposSortByHot(List<String> tags) {
9495
}
9596

9697
@Override
97-
public List<SimpleRepo> searchAndSortByTagPagination(List<String> tagName,
98+
public List<Repository> searchAndSortByTagPagination(List<String> tagName,
9899
Sort type, int currentPage, int itemsPerPage) {
99100
// TODO Auto-generated method stub
100101
int begin = (currentPage - 1) * itemsPerPage;
101102

102-
List<SimpleRepo> simpleRepos = new ArrayList<SimpleRepo>();
103+
List<Repository> simpleRepos = repositoryDao
104+
.getSimpleReposByTagNameAndSortPagination(tagName, type, begin,
105+
itemsPerPage);
103106

104-
if (type == Sort.GENERAL) {
105-
simpleRepos = repositoryDao
106-
.getSimpleReposByTagNameAndSortPagination(tagName,
107-
Sort.GENERAL, begin, itemsPerPage);
108-
} else if (type == Sort.STAR) {
109-
simpleRepos = repositoryDao
110-
.getSimpleReposByTagNameAndSortPagination(tagName,
111-
Sort.STAR, begin, itemsPerPage);
112-
} else if (type == Sort.FORK) {
113-
simpleRepos = repositoryDao
114-
.getSimpleReposByTagNameAndSortPagination(tagName,
115-
Sort.FORK, begin, itemsPerPage);
107+
for (int i = 0; i < simpleRepos.size(); i++) {
108+
simpleRepos.get(i).setCreate_time(
109+
simpleRepos.get(i).getCreate_time().substring(0, 10));
110+
simpleRepos.get(i).setUpdate_time(
111+
simpleRepos.get(i).getUpdate_time().substring(0, 10));
116112
}
117113
return simpleRepos;
118114
}
119115

120116
@Override
121117
public int resultCount(List<String> tagName, Sort type) {
122118
// TODO Auto-generated method stub
123-
int resultCount = 0;
124-
if (type == Sort.GENERAL) {
125-
resultCount = repositoryDao.getResultCountPagination(tagName,
126-
Sort.GENERAL);
127-
} else if (type == Sort.STAR) {
128-
resultCount = repositoryDao.getResultCountPagination(tagName,
129-
Sort.STAR);
130-
} else if (type == Sort.FORK) {
131-
resultCount = repositoryDao.getResultCountPagination(tagName,
132-
Sort.FORK);
133-
}
134-
return resultCount;
119+
return repositoryDao.getResultCountPagination(tagName, type);
135120
}
136121

137122
}

src/main/webapp/static/css/main.css

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,14 @@ a:hover {
246246
height: 180px;
247247
}
248248

249-
#repos .ui.segment .detaildes {
250-
position: absolute;
249+
#repoitems table .detaildes {
250+
overflow: hidden;
251+
height: 57px;
252+
text-overflow: ellipsis;
253+
color:#888;
251254
}
252255

253-
#repos .ui.segment .detaildes, .rightcontainer .ui.segment .detaildes {
256+
.rightcontainer .ui.segment .detaildes {
254257
top: 63px;
255258
overflow: hidden;
256259
height: 140px;
@@ -440,4 +443,27 @@ h4.ui.header .sub.header {
440443

441444
.page-list .page-total select {
442445
width: 50px;
446+
}
447+
448+
#repoitems table tr {
449+
height: 110px;
450+
}
451+
452+
#repoitems table tr td {
453+
vertical-align: super;
454+
}
455+
456+
#repoitems table tr td span{
457+
display:block;
458+
}
459+
460+
.span-number{
461+
/* color: #00B5AD !important; */
462+
font-weight:400;
463+
font-size:1.05em;
464+
color:#767676!important;
465+
}
466+
467+
.states {
468+
color: #888;
443469
}

0 commit comments

Comments
 (0)