Skip to content

Commit

Permalink
细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
jiashuaizhang committed Dec 12, 2021
1 parent e833353 commit ef26fe5
Show file tree
Hide file tree
Showing 23 changed files with 141 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ yarn-error.log*
*.njsproj
*.sln
*.iml
*.log
38 changes: 25 additions & 13 deletions yyets-history-ui/src/view/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="grid-content bg-purple-light div-content">
<el-form :inline="true" :model="searchForm" class="demo-form-inline">
<el-form-item label="剧目:" class="form-item">
<el-input v-model="searchForm.name" placeholder="剧目"></el-input>
<el-input v-model="searchForm.name" placeholder="剧目" keyup.enter=""></el-input>
</el-form-item>
<el-form-item class="form-item">
<el-button type="primary" :loading="loading" @click="onSubmit">查询</el-button>
Expand All @@ -13,7 +13,7 @@
<div>
<el-table
:data="tableData"
height="250"
:height="tableHeight"
border
style="width: 100%">
<el-table-column
Expand Down Expand Up @@ -43,14 +43,15 @@
width="350">
<template slot-scope="scope">
<el-button type="text" size="small" style="margin-left: 10px"
v-for="(item, i) in scope.row.seasons"
@click="viewSeason(scope.row, i)" :key="`${scope.row.id}${i}`">{{ item.name }}</el-button>
v-for="(item, i) in scope.row.seasons"
@click="viewSeason(scope.row, i)" :key="`${scope.row.id}${i}`">{{ item.name }}
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="750px">
<el-form :inline="true" class="demo-form-inline">
<el-form :inline="true" class="demo-form-inline">
<el-form-item label="资源分组:" class="form-item">
<el-select placeholder="资源分组" v-model="linkGroup" :change="linkGroupChange(linkGroup)">
<el-option
Expand Down Expand Up @@ -81,12 +82,13 @@
<el-table-column
fixed="right"
label="操作"
>
>
<template slot-scope="scope">
<el-button type="text" size="small" style="margin-left: 10px"
v-for="(item, i) in scope.row.links"
@click="dealLink(scope.row, i)"
:key="`${resourceRow.id}${scope.row.episode}${i}`">{{ item.way }}</el-button>
:key="`${resourceRow.id}${scope.row.episode}${i}`">{{ item.way }}
</el-button>
</template>
</el-table-column>
</el-table>
Expand All @@ -112,7 +114,8 @@
tableData: [],
dialogTitle: '资源列表',
linkGroup: 0,
operationType: 0
operationType: 0,
tableHeight: window.screen.height - 290
}
},
methods: {
Expand All @@ -128,14 +131,14 @@
this.dialogVisible = true;
},
linkGroupChange(linkGroup) {
if(!this.resourceRow.seasons || this.resourceRow.seasons.length === 0) {
if (!this.resourceRow.seasons || this.resourceRow.seasons.length === 0) {
return;
}
this.resourceLinksTableData = this.resourceLinks[linkGroup].items;
},
copyLink(link) {
let hiddenLink = document.getElementById('hiddenLink');
if(!hiddenLink) {
if (!hiddenLink) {
hiddenLink = document.createElement('textarea');
hiddenLink.style.display = 'none';
hiddenLink.id = 'hiddenLink';
Expand All @@ -151,7 +154,7 @@
dealLink(row, i) {
let link = row.links[i].address;
console.log(link);
if(this.operationType === 0) {
if (this.operationType === 0) {
this.copyLink(link);
} else {
this.$alert(`<textarea style="width:380px;height:60px;">${link}</textarea>`, '查看链接', {
Expand All @@ -160,7 +163,7 @@
}
},
onSubmit() {
if(!this.searchForm.name) {
if (!this.searchForm.name) {
this.$message({
message: '请输入剧目',
type: 'warning'
Expand All @@ -182,14 +185,23 @@
this.$message.error('查询失败');
});
}
},
created() {
document.onkeydown = e => {
let keyCode = e.code;
if (keyCode === 'Enter') {
this.onSubmit();
}
}
}
};
}
</script>
<style>
.div-content {
margin-top: 20px;
width: 100%;
}
.form-item {
margin-left: 20px;
float: left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.zhangjiashuai.yyetshistory.repository.ResourceRepository;
import com.zhangjiashuai.yyetshistory.repository.impl.ResourceRepositoryJdbcImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
Expand All @@ -15,4 +16,10 @@ public class AppConfig {
public ResourceRepository resourceRepository(JdbcTemplate jdbcTemplate) {
return new ResourceRepositoryJdbcImpl(jdbcTemplate);
}

@Bean
@ConfigurationProperties(prefix = "yyets-history")
public YyetsHistoryProperties yyetsHistoryConfig() {
return new YyetsHistoryProperties();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.zhangjiashuai.yyetshistory.config;

import lombok.Data;

import java.util.LinkedHashSet;

import static com.zhangjiashuai.yyetshistory.repository.impl.ResourceMapper.DEFAULT_PAGE_SIZE;

@Data
public class YyetsHistoryProperties {
/**
* 保留的链接类型
*/
private LinkedHashSet<String> linkWayFilter;

private int defaultPageSize;

public int getDefaultPageSize() {
return defaultPageSize < 1 ? DEFAULT_PAGE_SIZE : defaultPageSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public interface ResourceService {

default PageResult<Resource> selectPage(String name, int pageNo) {
PageResult<ResourceDO> doPageResult = selectDOPage(name, pageNo);
return doPageResult.stream().map(this::parseResource).collect(Collectors.toCollection(PageResult::new));
PageResult<Resource> pageResult = new PageResult<>(doPageResult.getPage(), doPageResult.getPageSize(), doPageResult.getTotal());
doPageResult.stream().map(this::parseResource).forEach(pageResult::add);
return pageResult;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zhangjiashuai.yyetshistory.config.YyetsHistoryProperties;
import com.zhangjiashuai.yyetshistory.entity.Resource;
import com.zhangjiashuai.yyetshistory.entity.ResourceDO;
import com.zhangjiashuai.yyetshistory.repository.ResourceRepository;
import com.zhangjiashuai.yyetshistory.service.ResourceService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class ResourceServiceImpl implements ResourceService {

private ResourceRepository resourceRepository;

public ResourceServiceImpl(ResourceRepository resourceRepository) {
private YyetsHistoryProperties configProperties;

public ResourceServiceImpl(ResourceRepository resourceRepository, YyetsHistoryProperties configProperties) {
this.resourceRepository = resourceRepository;
this.configProperties = configProperties;
}

@Override
public ResourceDO findById(long id) {
return resourceRepository.findById(id);
Expand Down Expand Up @@ -62,7 +64,7 @@ public Resource parseResource(ResourceDO resourceDO) {
throw new NullPointerException("info is null");
}
Resource resource = new Resource();
resource.setName(infoJson.getString("cnname"));
resource.setName(resourceDO.getName());
resource.setNameEN(infoJson.getString("enname"));
resource.setChannel(infoJson.getString("channel_cn"));
resource.setArea(infoJson.getString("area"));
Expand Down Expand Up @@ -109,7 +111,8 @@ public Resource parseResource(ResourceDO resourceDO) {
for (int k = 0; k < filesArray.size(); k++) {
JSONObject fileJson = filesArray.getJSONObject(k);
String way = fileJson.getString("way_cn");
if(!"电驴".equals(way) && !"磁力".equals(way)) {
LinkedHashSet<String> linkWayFilter = configProperties.getLinkWayFilter();
if(!linkWayFilter.contains(way)) {
continue;
}
String address = fileJson.getString("address");
Expand Down Expand Up @@ -169,6 +172,6 @@ public List<Resource> getAllResources() {

@Override
public PageResult<ResourceDO> selectDOPage(String name, int pageNo) {
return resourceRepository.selectPage(name, pageNo);
return resourceRepository.selectPage(name, pageNo, configProperties.getDefaultPageSize());
}
}
2 changes: 1 addition & 1 deletion yyets-history/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ logging:
level:
root: info
file:
name: workspace/logs/yyets-history.log
name: logs/yyets-history.log
#mybatis-plus:
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
7 changes: 6 additions & 1 deletion yyets-history/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ mybatis-plus:
configuration:
map-underscore-to-camel-case: true
server:
port: 9000
port: 9000
yyets-history:
link-way-filter: #保留的链接类型
- 电驴
- 磁力
default-page-size: 20 #默认的查询数量
2 changes: 1 addition & 1 deletion yyets-history/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>yyets-history-ui</title><link rel="shortcut icon" href=/favicon.ico><link href=/static/css/app.ed97e7e8937515c294f76315ce5bfecb.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.f23fa8a356970b349c2f.js></script><script type=text/javascript src=/static/js/app.7fc60c04eb1b43124b9a.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>yyets-history-ui</title><link rel="shortcut icon" href=/favicon.ico><link href=/static/css/app.ed97e7e8937515c294f76315ce5bfecb.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.fccd8c50e92f68dc616b.js></script><script type=text/javascript src=/static/js/app.0249f40201c76e10d025.js></script></body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit ef26fe5

Please sign in to comment.