Skip to content

Commit 2562a8d

Browse files
Merge branch 'develop' of https://github.com/serverdev-bewe/BEWE into FRONTEND/feature/#99
2 parents 0c09c91 + ffb9274 commit 2562a8d

File tree

9 files changed

+195
-100
lines changed

9 files changed

+195
-100
lines changed

BACKEND/PlatformApiServer/controllers/HashCtrl.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports.list = async(req, res, next) => {
88
try {
99
const hashIdx = req.params.string;
1010
let hashString;
11-
11+
1212
if(hashIdx == 2){
1313
hashString = '베스트UGC';
1414
}
@@ -19,4 +19,23 @@ exports.list = async(req, res, next) => {
1919
return next(error);
2020
}
2121
return res.status(200).json(result);
22-
};
22+
};
23+
24+
exports.newList = async(req, res, next) =>{
25+
let result ='';
26+
try {
27+
const curPageNo = req.body.pageNo;
28+
29+
let hashString = '베스트UGC';
30+
31+
// if(curPageNo == 2){
32+
// hashString = '베스트UGC';
33+
// }
34+
35+
result = await hashModel.newList(hashString, curPageNo)
36+
} catch (error) {
37+
console.log(error);
38+
return next(error);
39+
}
40+
return res.status(200).json(result);
41+
}

BACKEND/PlatformApiServer/models/hashModel.js

+69-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,82 @@
22

33
const pool = require('../util/db').pool;
44

5-
exports.list = (hashString, page) => {
5+
exports.list = (hashString) => {
66
return new Promise((resolve, reject) => {
7-
const sql = "SELECT * FROM hash WHERE hash_string = ?";
7+
const sql = "SELECT idx FROM hash WHERE tag = ?";
88

99
pool.query(sql, [hashString], (err, rows) => {
1010
if (err) {
1111
console.log(err);
1212
reject(err);
1313
} else {
14-
resolve(rows);
14+
resolve(rows[0].idx);
1515
}
1616
});
17-
});
17+
})
18+
.then((rows)=>{
19+
return new Promise((resolve, reject) =>{
20+
const sql = `
21+
SELECT
22+
b.title,
23+
b.contents,
24+
b.users_idx,
25+
b.created_at
26+
FROM boards_has_hash as bh
27+
LEFT JOIN boards as b
28+
ON bh.boards_idx = b.idx
29+
WHERE hash_idx = ?
30+
`;
31+
pool.query(sql, rows, (err, rows) => {
32+
if (err) {
33+
console.log(err);
34+
reject(err);
35+
} else {
36+
// rows = rows.slice(0, 8);
37+
resolve(rows);
38+
}
39+
});
40+
})
41+
})
42+
};
43+
44+
exports.newList = (hashString, page) => {
45+
return new Promise((resolve, reject) => {
46+
const sql = "SELECT idx FROM hash WHERE tag = ?";
47+
48+
pool.query(sql, hashString, (err, rows) => {
49+
if (err) {
50+
console.log(err);
51+
reject(err);
52+
} else {
53+
resolve(rows[0].idx);
54+
}
55+
});
56+
})
57+
.then((rows)=>{
58+
return new Promise((resolve, reject) =>{
59+
const sql = `
60+
SELECT
61+
b.title,
62+
b.contents,
63+
b.users_idx,
64+
b.created_at
65+
FROM boards_has_hash as bh
66+
LEFT JOIN boards as b
67+
ON bh.boards_idx = b.idx
68+
WHERE hash_idx = ?
69+
`;
70+
pool.query(sql, rows, (err, rows) => {
71+
if (err) {
72+
console.log(err);
73+
reject(err);
74+
} else {
75+
rows = rows.slice(0, page * 8 + 8);
76+
setTimeout(()=>{
77+
resolve(rows);
78+
}, 2000);
79+
}
80+
});
81+
})
82+
})
1883
};

BACKEND/PlatformApiServer/routes/hashApi.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ module.exports = (router) => {
55
router.route('/home/hash/:string')
66
.get(hashCtrl.list);
77

8+
router.route('/home/hash')
9+
.post(hashCtrl.newList);
10+
811
return router;
912
};

FRONTEND/ReactReduxVer_1/package-lock.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FRONTEND/ReactReduxVer_1/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"react-dom": "^0.14.9",
4242
"react-dropzone": "^4.2.7",
4343
"react-fade": "^1.1.1",
44+
"react-infinite-scroller": "^1.1.3",
4445
"react-modal": "^3.1.11",
4546
"react-moment": "^0.7.0",
4647
"react-redux": "4.3.0",

FRONTEND/ReactReduxVer_1/src/components/MyGameList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class MyGameList extends Component {
6464
<img src='https://i.ytimg.com/vi/S4Hnc_iRuBk/maxresdefault.jpg'
6565
alt='게임 다운로드'
6666
//img와 down링크 디비값으로 설정
67-
data-action="https://docs.google.com/kr?export=download&id=1c0vpBw4mFOB2oJKSg_CxjqXYOFCSwSkz"/>
67+
data-action="https://drive.google.com/uc?export=download&id=1c0vpBw4mFOB2oJKSg_CxjqXYOFCSwSkz"/>
6868
<img
6969
src='http://post.phinf.naver.net/MjAxNzAyMjdfMTM1/MDAxNDg4MTk0OTUxMzgx.DnQeRoSAEVGtGBJgLY2tmmjAtiujT_RYRjd5csfbTT0g.-GhV-au86bWwtaGBgrBOHoWeYs-RhIVCGEt8zDtQlMwg.PNG/IcoN3KjSbusLsg6-Lp1cKINXfHGc.jpg'
7070
alt='게임 다운로드'

FRONTEND/ReactReduxVer_1/src/components/chatt/ChatApp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ class ChatApp extends React.Component {
193193
readyUsers={this.state.readyUsers}
194194
/>
195195
{(this.state.execgameState) ?
196-
<Button className="mygame-chat-start-button"
197-
onClick={this.startgameHandler}>START</Button>
196+
<a href="BeWe://"><Button className="mygame-chat-start-button"
197+
onClick={this.startgameHandler}>START</Button></a>
198198
:
199199
<Button className="mygame-chat-ready-button"
200200
onClick={this.readyHandler}>READY</Button>

FRONTEND/ReactReduxVer_1/src/components/layout/body/BodyComponent.js

+89-89
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@ import {default as Fade} from 'react-fade'
66
import axios from 'axios';
77

88
import JumbotronB from './JumbotronB';
9+
import $ from 'jquery';
10+
911

1012
const fadeDuration = 0.3;
1113

1214
class BodyComponent extends Component {
1315
constructor(props) {
1416
super(props);
15-
17+
1618
this.toggle = this.toggle.bind(this);
19+
1720
this.state = {
1821
activeTab: '1',
19-
rows : []
22+
rows : [],
23+
pageNo : 0
24+
,loadingState: false
2025
};
2126
}
27+
28+
componentWillUnmount(){
29+
$(window).unbind();
30+
this.setState({
31+
rows: []
32+
})
33+
}
2234

2335
toggle(tab) {
2436
if (this.state.activeTab !== tab) {
@@ -27,21 +39,58 @@ class BodyComponent extends Component {
2739
});
2840
}
2941
if(tab == 2){
30-
axios.get(`http://localhost:3001/api/home/hash/${tab}`)
31-
.then((responseData) => {
32-
setTimeout(()=>{
33-
this.setState({
34-
rows:responseData.data
35-
})
36-
},1500);
37-
})
38-
.catch((err) => {
39-
console.log(err);
42+
$(window).scroll(() => {
43+
if ($(document).height() - $(window).height() - $(window).scrollTop() < 250) {
44+
if(!this.state.loadingState && this.state.rows.length < 40){
45+
46+
axios.post(`http://localhost:3001/api/home/hash`, {
47+
'pageNo' : this.state.pageNo
48+
})
49+
.then((rows)=>{
50+
console.log(rows);
51+
return rows
52+
})
53+
.then((rows)=>{
54+
this.setState({
55+
pageNo: this.state.pageNo + 1
56+
,rows : rows.data
57+
})
58+
})
59+
.catch((err) => {
60+
console.log(err);
61+
});
62+
this.setState({
63+
loadingState: true
64+
});
65+
}
66+
}else {
67+
if(this.state.loadingState){
68+
this.setState({
69+
loadingState: false
70+
});
71+
}
72+
}
4073
});
4174
}
42-
}
75+
}
76+
4377

4478
render() {
79+
const mapToComponents = (data) => {
80+
return data.map((contact, i )=>{
81+
return (
82+
<Col sm="3" key={i} style={{marginBottom:"3%"}}>
83+
<Card body>
84+
<CardTitle>{this.state.rows[i].title}</CardTitle>
85+
<hr />
86+
<CardText>{this.state.rows[i].contents}</CardText>
87+
<font style={{color:"blue", fontSize:"18"}}>#베스트UGC</font>
88+
<font style={{fontSize:"15"}}>{this.state.rows[i].created_at}</font>
89+
</Card>
90+
</Col>
91+
)
92+
})
93+
}
4594
return (
4695
<div>
4796

@@ -97,83 +146,34 @@ class BodyComponent extends Component {
97146
{
98147
this.state.rows.length !== 0
99148
?
100-
<div>
101-
<Fade
102-
duration={fadeDuration}
149+
<Fade duration={fadeDuration} >
150+
<Row style={{marginTop:"5%"}}>
151+
{mapToComponents(this.state.rows)}
152+
</Row>
153+
</Fade>
154+
:
155+
<center
156+
style={{marginTop:"10%"}}
103157
>
104-
<Row style={{marginTop:"5%"}}>
105-
<Col sm="3">
106-
<Card body>
107-
<CardTitle>{this.state.rows[0].title}</CardTitle>
108-
<CardText>{this.state.rows[0].contents}</CardText>
109-
<font style={{color:"blue", fontSize:"18"}}>#{this.state.rows[0].hash_string}</font>
110-
<font style={{fontSize:"15"}}>{this.state.rows[0].created_at}</font>
111-
<Button>읽어 보기</Button>
112-
</Card>
113-
</Col>
114-
<Col sm="3">
115-
<Card body>
116-
<CardTitle>Special Title Treatment</CardTitle>
117-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
118-
<Button>Go somewhere</Button>
119-
</Card>
120-
</Col>
121-
<Col sm="3">
122-
<Card body>
123-
<CardTitle>Special Title Treatment</CardTitle>
124-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
125-
<Button>Go somewhere</Button>
126-
</Card>
127-
</Col>
128-
<Col sm="3">
129-
<Card body>
130-
<CardTitle>Special Title Treatment</CardTitle>
131-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
132-
<Button>Go somewhere</Button>
133-
</Card>
134-
</Col>
135-
</Row>
136-
<Row style={{marginTop:"5%"}}>
137-
<Col sm="3">
138-
<Card body>
139-
<CardTitle>Special Title Treatment</CardTitle>
140-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
141-
<Button>Go somewhere</Button>
142-
</Card>
143-
</Col>
144-
<Col sm="3">
145-
<Card body>
146-
<CardTitle>Special Title Treatment</CardTitle>
147-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
148-
<Button>Go somewhere</Button>
149-
</Card>
150-
</Col>
151-
<Col sm="3">
152-
<Card body>
153-
<CardTitle>Special Title Treatment</CardTitle>
154-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
155-
<Button>Go somewhere</Button>
156-
</Card>
157-
</Col>
158-
<Col sm="3">
159-
<Card body>
160-
<CardTitle>Special Title Treatment</CardTitle>
161-
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
162-
<Button>Go somewhere</Button>
163-
</Card>
164-
</Col>
165-
</Row>
166-
</Fade>
167-
</div>
168-
:
169-
<center
170-
style={{marginTop:"10%"}}
171-
>
172-
<HashLoader
173-
color={'#7F7F7F'}
174-
loading={true}
175-
/>
176-
</center>
158+
<HashLoader
159+
color={'#7F7F7F'}
160+
loading={true}
161+
/>
162+
</center>
163+
}
164+
{
165+
this.state.rows.length < 37
166+
?
167+
<center
168+
style={{marginTop:"10%"}}
169+
>
170+
<HashLoader
171+
color={'#7F7F7F'}
172+
loading={true}
173+
/>
174+
</center>
175+
:
176+
''
177177
}
178178
</TabPane>
179179
<TabPane tabId="3">

0 commit comments

Comments
 (0)