송용우

Merge commit '89354c77'

Showing 81 changed files with 3951 additions and 0 deletions
1 +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 +
3 +# dependencies
4 +/node_modules
5 +/.pnp
6 +.pnp.js
7 +
8 +# testing
9 +/coverage
10 +
11 +# production
12 +/build
13 +
14 +# misc
15 +.DS_Store
16 +.env.local
17 +.env.development.local
18 +.env.test.local
19 +.env.production.local
20 +
21 +npm-debug.log*
22 +yarn-debug.log*
23 +yarn-error.log*
1 +{
2 + "singleQuote": true,
3 + "semi": true,
4 + "useTabs": false,
5 + "tabWidth": 2,
6 + "trailingComma": "all",
7 + "printWidth": 80
8 +}
1 +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 +
3 +## Available Scripts
4 +
5 +In the project directory, you can run:
6 +
7 +### `yarn start`
8 +
9 +Runs the app in the development mode.<br />
10 +Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 +
12 +The page will reload if you make edits.<br />
13 +You will also see any lint errors in the console.
14 +
15 +### `yarn test`
16 +
17 +Launches the test runner in the interactive watch mode.<br />
18 +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 +
20 +### `yarn build`
21 +
22 +Builds the app for production to the `build` folder.<br />
23 +It correctly bundles React in production mode and optimizes the build for the best performance.
24 +
25 +The build is minified and the filenames include the hashes.<br />
26 +Your app is ready to be deployed!
27 +
28 +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 +
30 +### `yarn eject`
31 +
32 +**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 +
34 +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 +
36 +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 +
38 +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 +
40 +## Learn More
41 +
42 +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 +
44 +To learn React, check out the [React documentation](https://reactjs.org/).
45 +
46 +### Code Splitting
47 +
48 +This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 +
50 +### Analyzing the Bundle Size
51 +
52 +This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 +
54 +### Making a Progressive Web App
55 +
56 +This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 +
58 +### Advanced Configuration
59 +
60 +This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 +
62 +### Deployment
63 +
64 +This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 +
66 +### `yarn build` fails to minify
67 +
68 +This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
1 +{
2 + "compilerOptions": {
3 + "target": "es6"
4 + }
5 +}
This diff could not be displayed because it is too large.
1 +{
2 + "name": "jaksimsamil-page",
3 + "version": "0.1.0",
4 + "private": true,
5 + "dependencies": {
6 + "@material-ui/core": "^4.10.2",
7 + "@testing-library/jest-dom": "^4.2.4",
8 + "@testing-library/react": "^9.3.2",
9 + "@testing-library/user-event": "^7.1.2",
10 + "axios": "^0.19.2",
11 + "immer": "^7.0.5",
12 + "include-media": "^1.4.9",
13 + "moment": "^2.27.0",
14 + "open-color": "^1.7.0",
15 + "react": "^16.13.1",
16 + "react-dom": "^16.13.1",
17 + "react-redux": "^7.2.0",
18 + "react-router-dom": "^5.2.0",
19 + "react-scripts": "3.4.1",
20 + "redux": "^4.0.5",
21 + "redux-actions": "^2.6.5",
22 + "redux-devtools-extension": "^2.13.8",
23 + "redux-saga": "^1.1.3",
24 + "styled-components": "^5.1.1"
25 + },
26 + "scripts": {
27 + "start": "react-scripts start",
28 + "build": "react-scripts build",
29 + "test": "react-scripts test",
30 + "eject": "react-scripts eject"
31 + },
32 + "eslintConfig": {
33 + "extends": "react-app"
34 + },
35 + "browserslist": {
36 + "production": [
37 + ">0.2%",
38 + "not dead",
39 + "not op_mini all"
40 + ],
41 + "development": [
42 + "last 1 chrome version",
43 + "last 1 firefox version",
44 + "last 1 safari version"
45 + ]
46 + },
47 + "proxy": "http://localhost:4000"
48 +}
No preview for this file type
1 +<!DOCTYPE html>
2 +<html lang="en">
3 + <head>
4 + <meta charset="utf-8" />
5 + <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6 + <meta name="viewport" content="width=device-width, initial-scale=1" />
7 + <meta name="theme-color" content="#000000" />
8 + <meta
9 + name="description"
10 + content="Web site created using create-react-app"
11 + />
12 + <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13 + <!--
14 + manifest.json provides metadata used when your web app is installed on a
15 + user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16 + -->
17 + <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18 + <!--
19 + Notice the use of %PUBLIC_URL% in the tags above.
20 + It will be replaced with the URL of the `public` folder during the build.
21 + Only files inside the `public` folder can be referenced from the HTML.
22 +
23 + Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24 + work correctly both with client-side routing and a non-root public URL.
25 + Learn how to configure a non-root public URL by running `npm run build`.
26 + -->
27 + <title>React App</title>
28 + </head>
29 + <body>
30 + <noscript>You need to enable JavaScript to run this app.</noscript>
31 + <div id="root"></div>
32 + <!--
33 + This HTML file is a template.
34 + If you open it directly in the browser, you will see an empty page.
35 +
36 + You can add webfonts, meta tags, or analytics to this file.
37 + The build step will place the bundled scripts into the <body> tag.
38 +
39 + To begin the development, run `npm start` or `yarn start`.
40 + To create a production bundle, use `npm run build` or `yarn build`.
41 + -->
42 + </body>
43 +</html>
1 +{
2 + "short_name": "React App",
3 + "name": "Create React App Sample",
4 + "icons": [
5 + {
6 + "src": "favicon.ico",
7 + "sizes": "64x64 32x32 24x24 16x16",
8 + "type": "image/x-icon"
9 + },
10 + {
11 + "src": "logo192.png",
12 + "type": "image/png",
13 + "sizes": "192x192"
14 + },
15 + {
16 + "src": "logo512.png",
17 + "type": "image/png",
18 + "sizes": "512x512"
19 + }
20 + ],
21 + "start_url": ".",
22 + "display": "standalone",
23 + "theme_color": "#000000",
24 + "background_color": "#ffffff"
25 +}
1 +# https://www.robotstxt.org/robotstxt.html
2 +User-agent: *
3 +Disallow:
1 +.App {
2 + text-align: center;
3 +}
4 +
5 +.App-logo {
6 + height: 40vmin;
7 + pointer-events: none;
8 +}
9 +
10 +@media (prefers-reduced-motion: no-preference) {
11 + .App-logo {
12 + animation: App-logo-spin infinite 20s linear;
13 + }
14 +}
15 +
16 +.App-header {
17 + background-color: #282c34;
18 + min-height: 100vh;
19 + display: flex;
20 + flex-direction: column;
21 + align-items: center;
22 + justify-content: center;
23 + font-size: calc(10px + 2vmin);
24 + color: white;
25 +}
26 +
27 +.App-link {
28 + color: #61dafb;
29 +}
30 +
31 +@keyframes App-logo-spin {
32 + from {
33 + transform: rotate(0deg);
34 + }
35 + to {
36 + transform: rotate(360deg);
37 + }
38 +}
1 +import React from 'react';
2 +import { Route } from 'react-router-dom';
3 +import './App.css';
4 +import LoginPage from './pages/LoginPage';
5 +import RegisterPage from './pages/RegisterPage';
6 +import HomePage from './pages/HomePage';
7 +import SettingPage from './pages/SettingPage';
8 +
9 +function App() {
10 + return (
11 + <>
12 + <Route component={HomePage} path={['/@:username', '/']} exact />
13 + <Route component={LoginPage} path="/login" />
14 + <Route component={RegisterPage} path="/register" />
15 + <Route component={SettingPage} path="/setting" />
16 + </>
17 + );
18 +}
19 +
20 +export default App;
1 +import React from 'react';
2 +import { render } from '@testing-library/react';
3 +import App from './App';
4 +
5 +test('renders learn react link', () => {
6 + const { getByText } = render(<App />);
7 + const linkElement = getByText(/learn react/i);
8 + expect(linkElement).toBeInTheDocument();
9 +});
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import { Link } from 'react-router-dom';
4 +import palette from '../../lib/styles/palette';
5 +import Button from '../common/Button';
6 +
7 +const AuthFormBlock = styled.div`
8 + h3 {
9 + margin: 0;
10 + color: ${palette.gray[8]};
11 + margin-bottom: 1rem;
12 + }
13 +`;
14 +
15 +const StyledInput = styled.input`
16 + font-size: 1rem;
17 + border: none;
18 + border-bottom: 1px solid ${palette.gray[5]};
19 + padding-bottom: 0.5rem;
20 + outline: none;
21 + width: 100%;
22 + &:focus {
23 + color: $oc-teal-7;
24 + border-bottom: 1px solid ${palette.gray[7]};
25 + }
26 + & + & {
27 + margin-top: 1rem;
28 + }
29 +`;
30 +
31 +const Footer = styled.div`
32 + margin-top: 2rem;
33 + text-align: right;
34 + a {
35 + color: ${palette.gray[6]};
36 + text-decoration: underline;
37 + &:hover {
38 + color: ${palette.gray[9]};
39 + }
40 + }
41 +`;
42 +
43 +const ButtonWithMarginTop = styled(Button)`
44 + margin-top: 1rem;
45 +`;
46 +
47 +const ErrorMessage = styled.div`
48 + color: red;
49 + text-align: center;
50 + font-size: 0.875rem;
51 + margin-top: 1rem;
52 +`;
53 +
54 +const textMap = {
55 + login: '로그인',
56 + register: '회원가입',
57 +};
58 +
59 +const AuthForm = ({ type, form, onChange, onSubmit, error }) => {
60 + const text = textMap[type];
61 + return (
62 + <AuthFormBlock>
63 + <h3>{text}</h3>
64 + <form onSubmit={onSubmit}>
65 + <StyledInput
66 + autoComplete="username"
67 + name="username"
68 + placeholder="아이디"
69 + onChange={onChange}
70 + value={form.username}
71 + />
72 + <StyledInput
73 + autoComplete="new-password"
74 + name="password"
75 + placeholder="비밀번호"
76 + type="password"
77 + onChange={onChange}
78 + value={form.password}
79 + />
80 + {type === 'register' && (
81 + <StyledInput
82 + autoComplete="new-password"
83 + name="passwordConfirm"
84 + placeholder="비밀번호 확인"
85 + type="password"
86 + onChange={onChange}
87 + value={form.passwordConfirm}
88 + />
89 + )}
90 + {error && <ErrorMessage>{error}</ErrorMessage>}
91 + <ButtonWithMarginTop cyan fullWidth>
92 + {text}
93 + </ButtonWithMarginTop>
94 + </form>
95 + <Footer>
96 + {type === 'login' ? (
97 + <Link to="/register">회원가입</Link>
98 + ) : (
99 + <Link to="/login">로그인</Link>
100 + )}
101 + </Footer>
102 + </AuthFormBlock>
103 + );
104 +};
105 +
106 +export default AuthForm;
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import palette from '../../lib/styles/palette';
4 +import { Link } from 'react-router-dom';
5 +/*
6 +register/login Layout
7 +*/
8 +const AuthTemplateBlock = styled.div`
9 + position: absolute;
10 + left: 0;
11 + top: 0;
12 + bottom: 0;
13 + right: 0;
14 + background: ${palette.gray[2]};
15 + display: flex;
16 + flex-direction: column;
17 + justify-content: center;
18 + align-items: center;
19 +`;
20 +
21 +const WhiteBox = styled.div`
22 + .logo-area {
23 + display: block;
24 + padding-bottom: 2rem;
25 + text-align: center;
26 + font-weight: bold;
27 + letter-spacing: 2px;
28 + }
29 + box-shadow: 0 0 8px rgba(0, 0, 0, 0.025);
30 + padding: 2rem;
31 + width: 360px;
32 + background: white;
33 + border-radius: 2px;
34 +`;
35 +
36 +const AuthTemplate = ({ children }) => {
37 + return (
38 + <AuthTemplateBlock>
39 + <WhiteBox>
40 + <div className="logo-area">
41 + <Link to="/">작심삼일</Link>
42 + </div>
43 + {children}
44 + </WhiteBox>
45 + </AuthTemplateBlock>
46 + );
47 +};
48 +
49 +export default AuthTemplate;
1 +import React from 'react';
2 +import styled, { css } from 'styled-components';
3 +import palette from '../../lib/styles/palette';
4 +import { withRouter } from 'react-router-dom';
5 +
6 +const StyledButton = styled.button`
7 + border: none;
8 + border-radius: 4px;
9 + font-size: 1rem;
10 + font-weight: bold;
11 + padding: 0.25rem 1rem;
12 + color: white;
13 + outline: none;
14 + cursor: pointer;
15 +
16 + background: ${palette.gray[8]};
17 + &:hover {
18 + background: ${palette.gray[6]};
19 + }
20 + ${props =>
21 + props.fullWidth &&
22 + css`
23 + padding-top: 0.75rem;
24 + padding-bottom: 0.75rem;
25 + width: 100%;
26 + font-size: 1.125rem;
27 + `}
28 +
29 + ${props =>
30 + props.cyan &&
31 + css`
32 + background: ${palette.cyan[5]};
33 + &:hover {
34 + background: ${palette.cyan[4]};
35 + }
36 + `}
37 +`;
38 +
39 +const Button = ({ to, history, ...rest }) => {
40 + const onClick = e => {
41 + if (to) {
42 + history.push(to);
43 + }
44 + if (rest.onClick) {
45 + rest.onClick(e);
46 + }
47 + };
48 + return <StyledButton {...rest} onClick={onClick} />;
49 +};
50 +export default withRouter(Button);
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import { NavLink } from 'react-router-dom';
4 +
5 +const categories = [
6 + {
7 + name: 'home',
8 + text: '홈',
9 + },
10 + {
11 + name: 'setting',
12 + text: '설정',
13 + },
14 +];
15 +
16 +const CategoriesBlock = styled.div`
17 + display: flex;
18 + padding: 1rem;
19 + margin: 0 auto;
20 + @media screen and (max-width: 768px) {
21 + width: 100%;
22 + overflow-x: auto;
23 + }
24 +`;
25 +
26 +const Category = styled(NavLink)`
27 + font-size: 1.2rem;
28 + cursor: pointer;
29 + white-space: pre;
30 + text-decoration: none;
31 + color: inherit;
32 + padding-bottom: 0.25rem;
33 + &:hover {
34 + color: #495057;
35 + }
36 + & + & {
37 + margin-left: 2rem;
38 + }
39 + &.active {
40 + font-weight: 600;
41 + border-bottom: 2px solid #22b8cf;
42 + color: #22b8cf;
43 + &:hover {
44 + color: #3bc9db;
45 + }
46 + }
47 +`;
48 +
49 +const Categories = () => {
50 + return (
51 + <CategoriesBlock>
52 + {categories.map((c) => (
53 + <Category
54 + activeClassName="active"
55 + key={c.name}
56 + exact={c.name === 'home'}
57 + to={c.name === 'home' ? '/' : `/${c.name}`}
58 + >
59 + {c.text}
60 + </Category>
61 + ))}
62 + </CategoriesBlock>
63 + );
64 +};
65 +
66 +export default Categories;
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +import Responsive from './Responsive';
4 +import Button from './Button';
5 +import { Link } from 'react-router-dom';
6 +import Categories from './Categories';
7 +
8 +const HeaderBlock = styled.div`
9 + position: fixed;
10 + width: 100%;
11 + background: white;
12 + box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.08);
13 +`;
14 +
15 +const Wrapper = styled(Responsive)`
16 + height: 4rem;
17 + display: flex;
18 + align-items: center;
19 + justify-content: space-between;
20 + .logo {
21 + font-size: 1.125rem;
22 + font-weight: 800;
23 + letter-spacing: 2px;
24 + }
25 + .right {
26 + display: flex;
27 + align-items: center;
28 + }
29 +`;
30 +
31 +const Spacer = styled.div`
32 + height: 4rem;
33 +`;
34 +const UserInfo = styled.div`
35 + font-weight: 800;
36 + margin-right: 1rem;
37 +`;
38 +
39 +const Header = ({ user, onLogout, category, onSelect }) => {
40 + return (
41 + <>
42 + <HeaderBlock>
43 + <Wrapper>
44 + <Link to="/" className="logo">
45 + 작심삼일
46 + </Link>
47 + <Categories
48 + category={category}
49 + onSelect={onSelect}
50 + className="right"
51 + />
52 + {user ? (
53 + <div className="right">
54 + <UserInfo>{user.username}</UserInfo>
55 + <Button onClick={onLogout}>로그아웃</Button>
56 + </div>
57 + ) : (
58 + <div className="right">
59 + <Button to="/login">로그인</Button>
60 + </div>
61 + )}
62 + </Wrapper>
63 + </HeaderBlock>
64 + <Spacer />
65 + </>
66 + );
67 +};
68 +
69 +export default Header;
1 +import React from 'react';
2 +import styled from 'styled-components';
3 +
4 +const ResponsiveBlock = styled.div`
5 + padding-left: 1rem;
6 + padding-right: 1rem;
7 + width: 1024px;
8 + margin: 0 auto;
9 +
10 + @media (max-width: 1024px) {
11 + width: 768px;
12 + }
13 + @media (max-width: 768px) {
14 + width: 100%;
15 + }
16 +`;
17 +
18 +const Responsive = ({ children, ...rest }) => {
19 + return <ResponsiveBlock {...rest}>{children}</ResponsiveBlock>;
20 +};
21 +
22 +export default Responsive;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Paper from '@material-ui/core/Paper';
4 +import Grid from '@material-ui/core/Grid';
5 +import palette from '../../lib/styles/palette';
6 +import AuthForm from '../auth/AuthForm';
7 +const useStyles = makeStyles((theme) => ({
8 + root: {
9 + flexGrow: 1,
10 + background: palette.gray[2],
11 + padding: theme.spacing(8),
12 + },
13 + paper: {
14 + padding: theme.spacing(8),
15 + margin: 'auto',
16 + textAlign: 'center',
17 + color: theme.palette.text.secondary,
18 + },
19 +}));
20 +const HomeForm = ({ PSdata, goalNum }) => {
21 + const classes = useStyles();
22 + return PSdata ? (
23 + <div className={classes.root}>
24 + <Grid container spacing={5}>
25 + <Grid item xs={12}>
26 + <Paper className={classes.paper}>
27 + <h1>{PSdata.recommend_data.problem_number}</h1>
28 + <h1>{PSdata.recommend_data.problem_title}</h1>
29 + <a
30 + href={'http://www.boj.kr/' + PSdata.recommend_data.problem_number}
31 + >
32 + 바로가기
33 + </a>
34 +
35 + <h3>오늘의 추천 문제</h3>
36 + </Paper>
37 + </Grid>
38 + <Grid item xs={6}>
39 + <Paper className={classes.paper}>
40 + <h1>{PSdata.presentNum + '/' + goalNum}</h1>
41 + <h3>오늘 문제</h3>
42 + </Paper>
43 + </Grid>
44 + <Grid item xs={6}>
45 + <Paper className={classes.paper}>
46 + <h1>{PSdata.latestSolve.problem_number}</h1>
47 + <h1>{PSdata.latestSolve.problem_title}</h1>
48 + <h3>마지막으로 문제</h3>
49 + </Paper>
50 + </Grid>
51 +
52 + <Grid item xs={4}>
53 + <Paper className={classes.paper}>
54 + <h1>{PSdata.weekNum}</h1>
55 + <h3>7</h3>
56 + </Paper>
57 + </Grid>
58 + <Grid item xs={4}>
59 + <Paper className={classes.paper}>
60 + <h1>{PSdata.monthNum}</h1>
61 + <h3>30</h3>
62 + </Paper>
63 + </Grid>
64 + <Grid item xs={4}>
65 + <Paper className={classes.paper}>
66 + <h1>{PSdata.totalNum}</h1>
67 + <h3>전체</h3>
68 + </Paper>
69 + </Grid>
70 + </Grid>
71 + </div>
72 + ) : (
73 + <div className={classes.root}>
74 + <Grid container spacing={5}>
75 + <Grid item xs={12}>
76 + <Paper className={classes.paper}>
77 + <h1></h1>
78 + <h3>오늘의 추천 문제</h3>
79 + </Paper>
80 + </Grid>
81 + <Grid item xs={6}>
82 + <Paper className={classes.paper}>
83 + <h1></h1>
84 + <h3>오늘</h3>
85 + </Paper>
86 + </Grid>
87 + <Grid item xs={6}>
88 + <Paper className={classes.paper}>
89 + <h1></h1>
90 + <h3>마지막 </h3>
91 + </Paper>
92 + </Grid>
93 +
94 + <Grid item xs={4}>
95 + <Paper className={classes.paper}>
96 + <h1></h1>
97 + <h3>7</h3>
98 + </Paper>
99 + </Grid>
100 + <Grid item xs={4}>
101 + <Paper className={classes.paper}>
102 + <h1></h1>
103 + <h3>30</h3>
104 + </Paper>
105 + </Grid>
106 + <Grid item xs={4}>
107 + <Paper className={classes.paper}>
108 + <h1></h1>
109 + <h3>전체</h3>
110 + </Paper>
111 + </Grid>
112 + </Grid>
113 + </div>
114 + );
115 +};
116 +
117 +export default HomeForm;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Button from '@material-ui/core/Button';
4 +import TextField from '@material-ui/core/TextField';
5 +
6 +const useStyles = makeStyles((theme) => ({
7 + root: {
8 + '& > *': {
9 + margin: theme.spacing(1),
10 + },
11 + },
12 + button: {
13 + margin: theme.spacing(1),
14 + },
15 +}));
16 +
17 +const BJIDForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => {
18 + const classes = useStyles();
19 + return (
20 + <div>
21 + <form>
22 + <TextField
23 + name="userBJID"
24 + onChange={onChange}
25 + value={profile.userBJID}
26 + placeholder="백준 아이디"
27 + label="백준 아이디"
28 + />
29 + </form>
30 + <Button
31 + className={classes.button}
32 + variant="outlined"
33 + onClick={onBJIDSubmit}
34 + color="primary"
35 + >
36 + 등록
37 + </Button>
38 + <Button
39 + className={classes.button}
40 + variant="outlined"
41 + onClick={onSyncBJIDSubmit}
42 + color="secondary"
43 + >
44 + 동기화
45 + </Button>
46 + </div>
47 + );
48 +};
49 +export default BJIDForm;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +
4 +import Button from '@material-ui/core/Button';
5 +import TextField from '@material-ui/core/TextField';
6 +
7 +const useStyles = makeStyles((theme) => ({
8 + root: {
9 + '& > *': {
10 + margin: theme.spacing(1),
11 + },
12 + },
13 + button: {
14 + margin: theme.spacing(1),
15 + },
16 +}));
17 +
18 +const GoalNumForm = ({ onChange, profile, onGoalNumSubmit }) => {
19 + const classes = useStyles();
20 + return (
21 + <div>
22 + <form>
23 + <TextField
24 + name="goalNum"
25 + type="number"
26 + onChange={onChange}
27 + value={profile.goalNum}
28 + placeholder="일일 목표"
29 + label="일일 목표"
30 + InputLabelProps={{
31 + shrink: true,
32 + }}
33 + />
34 + </form>
35 + <Button
36 + className={classes.button}
37 + onClick={onGoalNumSubmit}
38 + color="primary"
39 + variant="outlined"
40 + >
41 + 등록
42 + </Button>
43 + </div>
44 + );
45 +};
46 +
47 +export default GoalNumForm;
1 +import React from 'react';
2 +import palette from '../../lib/styles/palette';
3 +import BJIDForm from './BJIDForm';
4 +import SlackForm from './SlackForm';
5 +import GoalNumForm from './GoalNumForm';
6 +import { makeStyles } from '@material-ui/core/styles';
7 +import Paper from '@material-ui/core/Paper';
8 +import Grid from '@material-ui/core/Grid';
9 +import CircularProgress from '@material-ui/core/CircularProgress';
10 +import styled from 'styled-components';
11 +
12 +const useStyles = makeStyles((theme) => ({
13 + root: {
14 + flexGrow: 1,
15 + background: palette.gray[2],
16 + padding: theme.spacing(8),
17 + },
18 + paper: {
19 + padding: theme.spacing(8),
20 + margin: 'auto',
21 + textAlign: 'center',
22 + },
23 +}));
24 +
25 +const LoadingParentStyle = styled.div`
26 + display: flex;
27 + flex-direction: column;
28 + justify-content: center;
29 + align-items: center;
30 + padding-top: 20px;
31 +`;
32 +
33 +const SettingForm = ({
34 + onChange,
35 + onBJIDSubmit,
36 + onSlackURLSubmit,
37 + profile,
38 + onSyncBJIDSubmit,
39 + onGoalNumSubmit,
40 + isLoading,
41 +}) => {
42 + const classes = useStyles();
43 + return isLoading ? (
44 + <LoadingParentStyle>
45 + <CircularProgress className={classes.loading} />
46 + </LoadingParentStyle>
47 + ) : (
48 + <div className={classes.root}>
49 + <Grid container spacing={5}>
50 + <Grid container item xs={6}>
51 + <Paper className={classes.paper} elevation={3}>
52 + <h1>백준 아이디</h1>
53 + <BJIDForm
54 + profile={profile}
55 + onChange={onChange}
56 + onBJIDSubmit={onBJIDSubmit}
57 + onSyncBJIDSubmit={onSyncBJIDSubmit}
58 + />
59 + </Paper>
60 + </Grid>
61 +
62 + <Grid container item xs={6}>
63 + <Paper className={classes.paper} elevation={3}>
64 + <h1>슬랙 Hook URL</h1>
65 + <SlackForm
66 + profile={profile}
67 + onChange={onChange}
68 + onSlackURLSubmit={onSlackURLSubmit}
69 + />
70 + </Paper>
71 + </Grid>
72 +
73 + <Grid container item xs={6}>
74 + <Paper className={classes.paper} elevation={3}>
75 + <h1>일일 목표</h1>
76 + <GoalNumForm
77 + profile={profile}
78 + onChange={onChange}
79 + onGoalNumSubmit={onGoalNumSubmit}
80 + />
81 + </Paper>
82 + </Grid>
83 + </Grid>
84 + </div>
85 + );
86 +};
87 +
88 +export default SettingForm;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +
4 +import Button from '@material-ui/core/Button';
5 +import TextField from '@material-ui/core/TextField';
6 +
7 +const useStyles = makeStyles((theme) => ({
8 + root: {
9 + '& > *': {
10 + margin: theme.spacing(1),
11 + },
12 + },
13 + button: {
14 + margin: theme.spacing(1),
15 + },
16 +}));
17 +
18 +const SlackForm = ({ onChange, profile, onSlackURLSubmit }) => {
19 + const classes = useStyles();
20 + return (
21 + <div>
22 + <form>
23 + <TextField
24 + name="slackWebHookURL"
25 + onChange={onChange}
26 + value={profile.slackWebHookURL}
27 + placeholder="슬랙 Webhook URL"
28 + label="슬랙 Webhook URL"
29 + />
30 + </form>
31 + <Button
32 + className={classes.button}
33 + onSubmit={onSlackURLSubmit}
34 + variant="outlined"
35 + type="submit"
36 + color="primary"
37 + >
38 + 등록
39 + </Button>
40 + </div>
41 + );
42 +};
43 +
44 +export default SlackForm;
1 +import React, { useEffect, useState } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { withRouter } from 'react-router-dom';
4 +import { changeField, initializeForm, login } from '../../modules/auth';
5 +import AuthForm from '../../components/auth/AuthForm';
6 +import { check } from '../../modules/user';
7 +
8 +const LoginForm = ({ history }) => {
9 + const dispatch = useDispatch();
10 + const [error, setError] = useState(null);
11 + const { form, auth, authError, user } = useSelector(({ auth, user }) => ({
12 + form: auth.login,
13 + auth: auth.auth,
14 + authError: auth.authError,
15 + user: user.user,
16 + }));
17 +
18 + const onChange = (e) => {
19 + const { value, name } = e.target;
20 + dispatch(
21 + changeField({
22 + form: 'login',
23 + key: name,
24 + value,
25 + }),
26 + );
27 + };
28 +
29 + const onSubmit = (e) => {
30 + e.preventDefault();
31 + const { username, password } = form;
32 + dispatch(login({ username, password }));
33 + };
34 +
35 + useEffect(() => {
36 + dispatch(initializeForm('login'));
37 + }, [dispatch]);
38 +
39 + useEffect(() => {
40 + if (authError) {
41 + console.log('Error Occured');
42 + console.log(authError);
43 + setError('로그인 실패');
44 + return;
45 + }
46 + if (auth) {
47 + console.log('Login Success');
48 + dispatch(check());
49 + }
50 + }, [auth, authError, dispatch]);
51 +
52 + useEffect(() => {
53 + if (user) {
54 + history.push('/');
55 + try {
56 + localStorage.setItem('user', JSON.stringify(user));
57 + } catch (e) {
58 + console.log('localStorage is not working');
59 + }
60 + console.log(user);
61 + }
62 + }, [history, user]);
63 + return (
64 + <AuthForm
65 + type="login"
66 + form={form}
67 + onChange={onChange}
68 + onSubmit={onSubmit}
69 + error={error}
70 + ></AuthForm>
71 + );
72 +};
73 +
74 +export default withRouter(LoginForm);
1 +import React, { useEffect, useState } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { changeField, initializeForm, register } from '../../modules/auth';
4 +import AuthForm from '../../components/auth/AuthForm';
5 +import { check } from '../../modules/user';
6 +import { withRouter } from 'react-router-dom';
7 +
8 +const RegisterForm = ({ history }) => {
9 + const [error, setError] = useState(null);
10 + const dispatch = useDispatch();
11 + const { form, auth, authError, user } = useSelector(({ auth, user }) => ({
12 + form: auth.register,
13 + auth: auth.auth,
14 + authError: auth.authError,
15 + user: user.user,
16 + }));
17 +
18 + const onChange = (e) => {
19 + const { value, name } = e.target;
20 + dispatch(
21 + changeField({
22 + form: 'register',
23 + key: name,
24 + value,
25 + }),
26 + );
27 + };
28 +
29 + const onSubmit = (e) => {
30 + e.preventDefault();
31 + const { username, password, passwordConfirm } = form;
32 + if ([username, password, passwordConfirm].includes('')) {
33 + setError('빈 칸을 모두 입력하세요');
34 + return;
35 + }
36 + if (password !== passwordConfirm) {
37 + setError('비밀번호가 일치하지 않습니다.');
38 + changeField({ form: 'register', key: 'password', value: '' });
39 + changeField({ form: 'register', key: 'passwordConfirm', value: '' });
40 + return;
41 + }
42 + dispatch(register({ username, password }));
43 + };
44 +
45 + useEffect(() => {
46 + dispatch(initializeForm('register'));
47 + }, [dispatch]);
48 + useEffect(() => {
49 + if (authError) {
50 + if (authError.response.status === 409) {
51 + setError('이미 존재하는 계정명입니다.');
52 + return;
53 + }
54 + setError('회원가입 실패');
55 + return;
56 + }
57 +
58 + if (auth) {
59 + console.log('Register Success!');
60 + console.log(auth);
61 + dispatch(check());
62 + }
63 + }, [auth, authError, dispatch]);
64 +
65 + useEffect(() => {
66 + if (user) {
67 + console.log('SUCCESS check API');
68 + history.push('/');
69 + try {
70 + localStorage.setItem('user', JSON.stringify(user));
71 + } catch (e) {
72 + console.log('localStorage is not working');
73 + }
74 + }
75 + }, [history, user]);
76 + return (
77 + <AuthForm
78 + type="register"
79 + form={form}
80 + onChange={onChange}
81 + onSubmit={onSubmit}
82 + error={error}
83 + ></AuthForm>
84 + );
85 +};
86 +
87 +export default withRouter(RegisterForm);
1 +import React from 'react';
2 +import { useSelector, useDispatch } from 'react-redux';
3 +import Header from '../../components/common/Header';
4 +import { logout } from '../../modules/user';
5 +const HeaderContainer = () => {
6 + const { user } = useSelector(({ user }) => ({ user: user.user }));
7 +
8 + const dispatch = useDispatch();
9 + const onLogout = () => {
10 + dispatch(logout());
11 + };
12 + return <Header user={user} onLogout={onLogout} />;
13 +};
14 +export default HeaderContainer;
1 +import React, { useEffect } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { withRouter } from 'react-router-dom';
4 +import HomeForm from '../../components/home/HomeForm';
5 +import { getPROFILE, initializeProfile } from '../../modules/profile';
6 +const HomeContainer = ({ history }) => {
7 + const dispatch = useDispatch();
8 + const { user, profile } = useSelector(({ user, profile }) => ({
9 + user: user.user,
10 + profile: profile,
11 + }));
12 +
13 + useEffect(() => {
14 + if (!user) {
15 + alert('로그인이 필요합니다 ');
16 + history.push('/login');
17 + } else {
18 + let username = user.username;
19 + dispatch(getPROFILE({ username }));
20 + return () => {
21 + dispatch(initializeProfile());
22 + };
23 + }
24 + }, [dispatch, user, history]);
25 + useEffect(() => {
26 + console.log(profile);
27 + }, [profile]);
28 + useEffect(() => {
29 + if (user) {
30 + let username = user.username;
31 + dispatch(getPROFILE({ username }));
32 + }
33 + }, [dispatch, user]);
34 + return <HomeForm PSdata={profile.solvedBJ_date} goalNum={profile.goalNum} />;
35 +};
36 +export default withRouter(HomeContainer);
1 +import React, { useEffect, useState } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +
4 +import { withRouter } from 'react-router-dom';
5 +import {
6 + changeField,
7 + setBJID,
8 + getPROFILE,
9 + syncBJID,
10 + initializeProfile,
11 + setSLACK,
12 + setGOALNUM,
13 +} from '../../modules/profile';
14 +import SettingForm from '../../components/setting/SettingForm';
15 +
16 +const SettingContainer = ({ history }) => {
17 + const [isLoading, setLoading] = useState(false);
18 +
19 + const dispatch = useDispatch();
20 + const { user, profile, loading } = useSelector(
21 + ({ user, profile, loading }) => ({
22 + user: user.user,
23 + profile: profile,
24 + loading: loading,
25 + }),
26 + );
27 +
28 + const onChange = (e) => {
29 + const { value, name } = e.target;
30 + dispatch(
31 + changeField({
32 + key: name,
33 + value: value,
34 + }),
35 + );
36 + };
37 +
38 + const onSyncBJIDSubmit = (e) => {
39 + e.preventDefault();
40 + let username = profile.username;
41 + dispatch(syncBJID({ username }));
42 + };
43 +
44 + const onGoalNumSubmit = (e) => {
45 + e.preventDefault();
46 + let username = profile.username;
47 + let goalNum = profile.goalNum;
48 + dispatch(setGOALNUM({ username, goalNum }));
49 + };
50 + const onSlackURLSubmit = (e) => {
51 + e.preventDefault();
52 + let username = profile.username;
53 + let slackWebHookURL = profile.slackWebHookURL;
54 + dispatch(setSLACK({ username, slackWebHookURL }));
55 + };
56 +
57 + const onBJIDSubmit = (e) => {
58 + e.preventDefault();
59 + let username = profile.username;
60 + let userBJID = profile.userBJID;
61 +
62 + dispatch(setBJID({ username, userBJID }));
63 + };
64 +
65 + useEffect(() => {
66 + if (!user) {
67 + alert('로그인이 필요합니다 ');
68 + history.push('/login');
69 + } else {
70 + let username = user.username;
71 + dispatch(getPROFILE({ username }));
72 + return () => {
73 + dispatch(initializeProfile());
74 + };
75 + }
76 + }, [dispatch, user, history]);
77 + useEffect(() => {
78 + if (loading['profile/SYNC_BJID'] == true) {
79 + setLoading(true);
80 + } else {
81 + setLoading(false);
82 + }
83 + }, [dispatch, loading]);
84 +
85 + return (
86 + <div>
87 + <SettingForm
88 + type="setting"
89 + onChange={onChange}
90 + onBJIDSubmit={onBJIDSubmit}
91 + onSyncBJIDSubmit={onSyncBJIDSubmit}
92 + onSlackURLSubmit={onSlackURLSubmit}
93 + onGoalNumSubmit={onGoalNumSubmit}
94 + profile={profile}
95 + isLoading={isLoading}
96 + ></SettingForm>
97 + </div>
98 + );
99 +};
100 +
101 +export default withRouter(SettingContainer);
1 +body {
2 + margin: 0;
3 + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 + sans-serif;
6 + -webkit-font-smoothing: antialiased;
7 + -moz-osx-font-smoothing: grayscale;
8 + box-sizing: border-box;
9 + min-height: 100%;
10 +}
11 +
12 +#root {
13 + min-height: 100%;
14 +}
15 +
16 +html {
17 + height: 100%;
18 +}
19 +
20 +a {
21 + color: inherit;
22 + text-decoration: none;
23 +}
24 +* {
25 + box-sizing: inherit;
26 +}
27 +
28 +code {
29 + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
30 + monospace;
31 +}
1 +import React from 'react';
2 +import ReactDOM from 'react-dom';
3 +import './index.css';
4 +import App from './App';
5 +import * as serviceWorker from './serviceWorker';
6 +import { BrowserRouter } from 'react-router-dom';
7 +import { Provider } from 'react-redux';
8 +import { createStore, applyMiddleware } from 'redux';
9 +import { composeWithDevTools } from 'redux-devtools-extension';
10 +import createSagaMiddleware from 'redux-saga';
11 +import rootReducer, { rootSaga } from './modules';
12 +import { tempSetUser, check } from './modules/user';
13 +
14 +const sagaMiddleware = createSagaMiddleware();
15 +const store = createStore(
16 + rootReducer,
17 + composeWithDevTools(applyMiddleware(sagaMiddleware)),
18 +);
19 +
20 +function loadUser() {
21 + try {
22 + const user = localStorage.getItem('user');
23 + if (!user) return;
24 +
25 + store.dispatch(tempSetUser(user));
26 + store.dispatch(check());
27 + } catch (e) {
28 + console.log('localStorage is not working');
29 + }
30 +}
31 +sagaMiddleware.run(rootSaga);
32 +loadUser();
33 +
34 +ReactDOM.render(
35 + <Provider store={store}>
36 + <BrowserRouter>
37 + <App />
38 + </BrowserRouter>
39 + </Provider>,
40 + document.getElementById('root'),
41 +);
42 +
43 +// If you want your app to work offline and load faster, you can change
44 +// unregister() to register() below. Note this comes with some pitfalls.
45 +// Learn more about service workers: https://bit.ly/CRA-PWA
46 +serviceWorker.unregister();
1 +import client from './client';
2 +
3 +export const login = ({ username, password }) =>
4 + client.post('api/auth/login', { username, password });
5 +
6 +export const register = ({ username, password }) =>
7 + client.post('api/auth/register', { username, password });
8 +
9 +export const check = () => client.get('api/auth/check');
10 +
11 +export const logout = () => client.post('/api/auth/logout');
1 +import axios from 'axios';
2 +const client = axios.create();
3 +export default client;
1 +import client from './client';
2 +
3 +export const setBJID = ({ username, userBJID }) =>
4 + client.post('api/profile/setprofile', {
5 + username: username,
6 + userBJID: userBJID,
7 + });
8 +export const setPROFILE = (postdata) =>
9 + client.post('api/profile/setprofile', postdata);
10 +export const getPROFILE = ({ username }) =>
11 + client.post('api/profile/getprofile', { username });
12 +
13 +export const syncBJ = ({ username }) =>
14 + client.patch('api/profile/syncBJ', { username });
1 +import { call, put } from 'redux-saga/effects';
2 +import { startLoading, finishLoading } from '../modules/loading';
3 +
4 +export const createRequestActionTypes = (type) => {
5 + const SUCCESS = `${type}_SUCCESS`;
6 + const FAILURE = `${type}_FAILURE`;
7 + return [type, SUCCESS, FAILURE];
8 +};
9 +
10 +export default function createRequestSaga(type, request) {
11 + const SUCCESS = `${type}_SUCCESS`;
12 + const FAILURE = `${type}_FAILURE`;
13 +
14 + return function* (action) {
15 + yield put(startLoading(type));
16 + try {
17 + const response = yield call(request, action.payload);
18 + yield put({
19 + type: SUCCESS,
20 + payload: response.data,
21 + });
22 + } catch (e) {
23 + yield put({
24 + type: FAILURE,
25 + payload: e,
26 + error: true,
27 + });
28 + }
29 + yield put(finishLoading(type));
30 + };
31 +}
1 +// source: https://yeun.github.io/open-color/
2 +
3 +const palette = {
4 + gray: [
5 + '#f8f9fa',
6 + '#f1f3f5',
7 + '#e9ecef',
8 + '#dee2e6',
9 + '#ced4da',
10 + '#adb5bd',
11 + '#868e96',
12 + '#495057',
13 + '#343a40',
14 + '#212529',
15 + ],
16 + cyan: [
17 + '#e3fafc',
18 + '#c5f6fa',
19 + '#99e9f2',
20 + '#66d9e8',
21 + '#3bc9db',
22 + '#22b8cf',
23 + '#15aabf',
24 + '#1098ad',
25 + '#0c8599',
26 + '#0b7285',
27 + ],
28 +};
29 +
30 +export default palette;
1 +import { createAction, handleActions } from 'redux-actions';
2 +import produce from 'immer';
3 +import { takeLatest } from 'redux-saga/effects';
4 +import createRequestSaga, {
5 + createRequestActionTypes,
6 +} from '../lib/createRequestSaga';
7 +import * as authAPI from '../lib/api/auth';
8 +const CHANGE_FIELD = 'auth/CHANGE_FIELD';
9 +const INITIALIZE_FORM = 'auth/INITIALIZE_FORM';
10 +
11 +const [REGISTER, REGISTER_SUCCESS, REGISTER_FAILURE] = createRequestActionTypes(
12 + 'auth/REGISTER',
13 +);
14 +
15 +const [LOGIN, LOGIN_SUCCESS, LOGIN_FAILURE] = createRequestActionTypes(
16 + 'auth/REGISTER',
17 +);
18 +
19 +export const changeField = createAction(
20 + CHANGE_FIELD,
21 + ({ form, key, value }) => ({
22 + form,
23 + key,
24 + value,
25 + }),
26 +);
27 +export const initializeForm = createAction(INITIALIZE_FORM, (form) => form);
28 +
29 +const initalState = {
30 + register: {
31 + username: '',
32 + password: '',
33 + passwordConfirm: '',
34 + },
35 + login: {
36 + username: '',
37 + password: '',
38 + },
39 + auth: null,
40 + authError: null,
41 +};
42 +
43 +export const register = createAction(REGISTER, ({ username, password }) => ({
44 + username,
45 + password,
46 +}));
47 +export const login = createAction(LOGIN, ({ username, password }) => ({
48 + username,
49 + password,
50 +}));
51 +
52 +const registerSaga = createRequestSaga(REGISTER, authAPI.register);
53 +const loginSaga = createRequestSaga(LOGIN, authAPI.login);
54 +
55 +export function* authSaga() {
56 + yield takeLatest(REGISTER, registerSaga);
57 + yield takeLatest(LOGIN, loginSaga);
58 +}
59 +
60 +const auth = handleActions(
61 + {
62 + [CHANGE_FIELD]: (state, { payload: { form, key, value } }) =>
63 + produce(state, (draft) => {
64 + draft[form][key] = value;
65 + }),
66 + [INITIALIZE_FORM]: (state, { payload: form }) => ({
67 + ...state,
68 + [form]: initalState[form],
69 + authError: null,
70 + }),
71 + [REGISTER_SUCCESS]: (state, { payload: auth }) => ({
72 + ...state,
73 + authError: null,
74 + auth,
75 + }),
76 + [REGISTER_FAILURE]: (state, { payload: error }) => ({
77 + ...state,
78 + authError: error,
79 + }),
80 + [LOGIN_SUCCESS]: (state, { payload: auth }) => ({
81 + ...state,
82 + authError: null,
83 + auth,
84 + }),
85 + [LOGIN_FAILURE]: (state, { payload: error }) => ({
86 + ...state,
87 + authError: error,
88 + }),
89 + },
90 + initalState,
91 +);
92 +
93 +export default auth;
1 +import { combineReducers } from 'redux';
2 +import { all } from 'redux-saga/effects';
3 +import auth, { authSaga } from './auth';
4 +import loading from './loading';
5 +import user, { userSaga } from './user';
6 +import profile, { profileSaga } from './profile';
7 +
8 +const rootReducer = combineReducers({
9 + auth,
10 + loading,
11 + user,
12 + profile,
13 +});
14 +
15 +export function* rootSaga() {
16 + yield all([authSaga(), userSaga(), profileSaga()]);
17 +}
18 +
19 +export default rootReducer;
1 +import { createAction, handleActions } from 'redux-actions';
2 +
3 +const START_LOADING = 'loading/START_LOADING';
4 +const FINISH_LOADING = 'loading/FINISH_LOADING';
5 +
6 +export const startLoading = createAction(
7 + START_LOADING,
8 + (requestType) => requestType,
9 +);
10 +
11 +export const finishLoading = createAction(
12 + FINISH_LOADING,
13 + (requestType) => requestType,
14 +);
15 +
16 +const initialState = {};
17 +
18 +const loading = handleActions(
19 + {
20 + [START_LOADING]: (state, action) => ({
21 + ...state,
22 + [action.payload]: true,
23 + }),
24 + [FINISH_LOADING]: (state, action) => ({
25 + ...state,
26 + [action.payload]: false,
27 + }),
28 + },
29 + initialState,
30 +);
31 +
32 +export default loading;
1 +import { createAction, handleActions } from 'redux-actions';
2 +import createRequestSaga, {
3 + createRequestActionTypes,
4 +} from '../lib/createRequestSaga';
5 +import produce from 'immer';
6 +import * as profileAPI from '../lib/api/profile';
7 +import { takeLatest } from 'redux-saga/effects';
8 +
9 +const INITIALIZE = 'profile/INITIALIZE';
10 +const CHANGE_FIELD = 'profile/CHANGE_FIELD';
11 +const [SET_BJID, SET_BJID_SUCCESS, SET_BJID_FAILURE] = createRequestActionTypes(
12 + 'profile/SET_BJID',
13 +);
14 +const [
15 + SET_SLACK,
16 + SET_SLACK_SUCCESS,
17 + SET_SLACK_FAILURE,
18 +] = createRequestActionTypes('/profile/SET_SLACK');
19 +const [
20 + SET_GOALNUM,
21 + SET_GOALNUM_SUCCESS,
22 + SET_GOALNUM_FAILURE,
23 +] = createRequestActionTypes('/profile/SET_GOALNUM');
24 +const [
25 + GET_PROFILE,
26 + GET_PROFILE_SUCCESS,
27 + GET_PROFILE_FAILURE,
28 +] = createRequestActionTypes('profile/GET_PROFILE');
29 +
30 +const [
31 + SYNC_BJID,
32 + SYNC_BJID_SUCCESS,
33 + SYNC_BJID_FAILURE,
34 +] = createRequestActionTypes('profile/SYNC_BJID');
35 +export const initializeProfile = createAction(INITIALIZE);
36 +export const syncBJID = createAction(SYNC_BJID, ({ username }) => ({
37 + username,
38 +}));
39 +
40 +export const setSLACK = createAction(
41 + SET_SLACK,
42 + ({ username, slackWebHookURL }) => ({
43 + username,
44 + slackWebHookURL,
45 + }),
46 +);
47 +
48 +export const setGOALNUM = createAction(
49 + SET_GOALNUM,
50 + ({ username, goalNum }) => ({
51 + username,
52 + goalNum,
53 + }),
54 +);
55 +export const setBJID = createAction(SET_BJID, ({ username, userBJID }) => ({
56 + username,
57 + userBJID,
58 +}));
59 +
60 +export const changeField = createAction(CHANGE_FIELD, ({ key, value }) => ({
61 + key,
62 + value,
63 +}));
64 +
65 +export const getPROFILE = createAction(GET_PROFILE, ({ username }) => ({
66 + username,
67 +}));
68 +const initialState = {
69 + username: '',
70 + userBJID: '',
71 + solvedBJ: '',
72 + friendList: [],
73 + profileError: '',
74 + slackWebHookURL: '',
75 + solvedBJ_date: '',
76 + goalNum: '',
77 +};
78 +const getPROFILESaga = createRequestSaga(GET_PROFILE, profileAPI.getPROFILE);
79 +const setBJIDSaga = createRequestSaga(SET_BJID, profileAPI.setBJID);
80 +const setSLACKSaga = createRequestSaga(SET_SLACK, profileAPI.setPROFILE);
81 +const setGOALNUMSaga = createRequestSaga(SET_GOALNUM, profileAPI.setPROFILE);
82 +const syncBJIDSaga = createRequestSaga(SYNC_BJID, profileAPI.syncBJ);
83 +
84 +export function* profileSaga() {
85 + yield takeLatest(SET_BJID, setBJIDSaga);
86 + yield takeLatest(GET_PROFILE, getPROFILESaga);
87 + yield takeLatest(SYNC_BJID, syncBJIDSaga);
88 + yield takeLatest(SET_SLACK, setSLACKSaga);
89 + yield takeLatest(SET_GOALNUM, setGOALNUMSaga);
90 +}
91 +
92 +export default handleActions(
93 + {
94 + [INITIALIZE]: (state) => initialState,
95 + [CHANGE_FIELD]: (state, { payload: { key, value } }) =>
96 + produce(state, (draft) => {
97 + draft[key] = value;
98 + }),
99 + [GET_PROFILE_SUCCESS]: (
100 + state,
101 + {
102 + payload: {
103 + username,
104 + userBJID,
105 + solvedBJ,
106 + friendList,
107 + slackWebHookURL,
108 + solvedBJ_date,
109 + goalNum,
110 + },
111 + },
112 + ) => ({
113 + ...state,
114 + username: username,
115 + userBJID: userBJID,
116 + solvedBJ: solvedBJ,
117 + friendList: friendList,
118 + profileError: null,
119 + slackWebHookURL: slackWebHookURL,
120 + solvedBJ_date: solvedBJ_date,
121 + goalNum: goalNum,
122 + }),
123 + [GET_PROFILE_FAILURE]: (state, { payload: error }) => ({
124 + ...state,
125 + profileError: error,
126 + }),
127 +
128 + [SET_BJID_SUCCESS]: (state, { payload: { userBJID } }) => ({
129 + ...state,
130 + userBJID: userBJID,
131 + profileError: null,
132 + }),
133 + [SET_BJID_FAILURE]: (state, { payload: error }) => ({
134 + ...state,
135 + profileError: error,
136 + }),
137 + [SET_SLACK_SUCCESS]: (state, { payload: { slackWebHookURL } }) => ({
138 + ...state,
139 + slackWebHookURL: slackWebHookURL,
140 + profileError: null,
141 + }),
142 + [SET_SLACK_FAILURE]: (state, { payload: error }) => ({
143 + ...state,
144 + profileError: error,
145 + }),
146 + [SET_GOALNUM_SUCCESS]: (state, { payload: { goalNum } }) => ({
147 + ...state,
148 + goalNum: goalNum,
149 + }),
150 + [SET_GOALNUM_FAILURE]: (state, { payload: error }) => ({
151 + ...state,
152 + profileError: error,
153 + }),
154 + [SYNC_BJID_SUCCESS]: (state, { payload: { solvedBJ } }) => ({
155 + ...state,
156 + solvedBJ,
157 + profileError: null,
158 + }),
159 + [SYNC_BJID_FAILURE]: (state, { payload: error }) => ({
160 + ...state,
161 + profileError: error,
162 + }),
163 + },
164 + initialState,
165 +);
1 +import { createAction, handleActions } from 'redux-actions';
2 +import { takeLatest, call } from 'redux-saga/effects';
3 +import * as authAPI from '../lib/api/auth';
4 +import createRequestSaga, {
5 + createRequestActionTypes,
6 +} from '../lib/createRequestSaga';
7 +
8 +const TEMP_SET_USER = 'user/TEMP_SET_USER';
9 +const [CHECK, CHECK_SUCCESS, CHECK_FAILURE] = createRequestActionTypes(
10 + 'user/CHECK',
11 +);
12 +const LOGOUT = 'user/LOGOUT';
13 +
14 +export const tempSetUser = createAction(TEMP_SET_USER, (user) => user);
15 +export const check = createAction(CHECK);
16 +export const logout = createAction(LOGOUT);
17 +const checkSaga = createRequestSaga(CHECK, authAPI.check);
18 +function checkFailureSaga() {
19 + try {
20 + localStorage.removeItem('user');
21 + } catch (e) {
22 + console.log('localStroage is not working');
23 + }
24 +}
25 +function* logoutSaga() {
26 + try {
27 + yield call(authAPI.logout);
28 + console.log('logout');
29 + localStorage.removeItem('user');
30 + } catch (e) {
31 + console.log(e);
32 + }
33 +}
34 +export function* userSaga() {
35 + yield takeLatest(CHECK, checkSaga);
36 + yield takeLatest(CHECK_FAILURE, checkFailureSaga);
37 + yield takeLatest(LOGOUT, logoutSaga);
38 +}
39 +
40 +const initialState = {
41 + user: null,
42 + checkError: null,
43 +};
44 +
45 +export default handleActions(
46 + {
47 + [TEMP_SET_USER]: (state, { payload: user }) => ({
48 + ...state,
49 + user,
50 + }),
51 + [CHECK_SUCCESS]: (state, { payload: user }) => ({
52 + ...state,
53 + user,
54 + checkError: null,
55 + }),
56 + [CHECK_FAILURE]: (state, { payload: error }) => ({
57 + ...state,
58 + user: null,
59 + checkError: error,
60 + }),
61 + [LOGOUT]: (state) => ({
62 + ...state,
63 + user: null,
64 + }),
65 + },
66 + initialState,
67 +);
1 +import React from 'react';
2 +import HeaderContainer from '../containers/common/HeaderContainer';
3 +import HomeContainer from '../containers/home/HomeContainer';
4 +
5 +const HomePage = () => {
6 + return (
7 + <div>
8 + <HeaderContainer />
9 + <HomeContainer />
10 + </div>
11 + );
12 +};
13 +
14 +export default HomePage;
1 +import React from 'react';
2 +import AuthTemplate from '../components/auth/AuthTemplate';
3 +import LoginForm from '../containers/auth/LoginForm';
4 +
5 +const LoginPage = () => {
6 + return (
7 + <AuthTemplate>
8 + <LoginForm type="login" />
9 + </AuthTemplate>
10 + );
11 +};
12 +
13 +export default LoginPage;
1 +import React from 'react';
2 +import AuthTemplate from '../components/auth/AuthTemplate';
3 +import RegisterForm from '../containers/auth/RegisterForm';
4 +
5 +const RegisterPage = () => {
6 + return (
7 + <AuthTemplate>
8 + <RegisterForm type="register" />
9 + </AuthTemplate>
10 + );
11 +};
12 +
13 +export default RegisterPage;
1 +import React from 'react';
2 +import HeaderContainer from '../containers/common/HeaderContainer';
3 +import SettingContainer from '../containers/setting/SettingContainer';
4 +
5 +const SettingPage = () => {
6 + return (
7 + <div>
8 + <HeaderContainer />
9 + <SettingContainer></SettingContainer>
10 + </div>
11 + );
12 +};
13 +
14 +export default SettingPage;
1 +// This optional code is used to register a service worker.
2 +// register() is not called by default.
3 +
4 +// This lets the app load faster on subsequent visits in production, and gives
5 +// it offline capabilities. However, it also means that developers (and users)
6 +// will only see deployed updates on subsequent visits to a page, after all the
7 +// existing tabs open on the page have been closed, since previously cached
8 +// resources are updated in the background.
9 +
10 +// To learn more about the benefits of this model and instructions on how to
11 +// opt-in, read https://bit.ly/CRA-PWA
12 +
13 +const isLocalhost = Boolean(
14 + window.location.hostname === 'localhost' ||
15 + // [::1] is the IPv6 localhost address.
16 + window.location.hostname === '[::1]' ||
17 + // 127.0.0.0/8 are considered localhost for IPv4.
18 + window.location.hostname.match(
19 + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 + )
21 +);
22 +
23 +export function register(config) {
24 + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 + // The URL constructor is available in all browsers that support SW.
26 + const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 + if (publicUrl.origin !== window.location.origin) {
28 + // Our service worker won't work if PUBLIC_URL is on a different origin
29 + // from what our page is served on. This might happen if a CDN is used to
30 + // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 + return;
32 + }
33 +
34 + window.addEventListener('load', () => {
35 + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 +
37 + if (isLocalhost) {
38 + // This is running on localhost. Let's check if a service worker still exists or not.
39 + checkValidServiceWorker(swUrl, config);
40 +
41 + // Add some additional logging to localhost, pointing developers to the
42 + // service worker/PWA documentation.
43 + navigator.serviceWorker.ready.then(() => {
44 + console.log(
45 + 'This web app is being served cache-first by a service ' +
46 + 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 + );
48 + });
49 + } else {
50 + // Is not localhost. Just register service worker
51 + registerValidSW(swUrl, config);
52 + }
53 + });
54 + }
55 +}
56 +
57 +function registerValidSW(swUrl, config) {
58 + navigator.serviceWorker
59 + .register(swUrl)
60 + .then(registration => {
61 + registration.onupdatefound = () => {
62 + const installingWorker = registration.installing;
63 + if (installingWorker == null) {
64 + return;
65 + }
66 + installingWorker.onstatechange = () => {
67 + if (installingWorker.state === 'installed') {
68 + if (navigator.serviceWorker.controller) {
69 + // At this point, the updated precached content has been fetched,
70 + // but the previous service worker will still serve the older
71 + // content until all client tabs are closed.
72 + console.log(
73 + 'New content is available and will be used when all ' +
74 + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 + );
76 +
77 + // Execute callback
78 + if (config && config.onUpdate) {
79 + config.onUpdate(registration);
80 + }
81 + } else {
82 + // At this point, everything has been precached.
83 + // It's the perfect time to display a
84 + // "Content is cached for offline use." message.
85 + console.log('Content is cached for offline use.');
86 +
87 + // Execute callback
88 + if (config && config.onSuccess) {
89 + config.onSuccess(registration);
90 + }
91 + }
92 + }
93 + };
94 + };
95 + })
96 + .catch(error => {
97 + console.error('Error during service worker registration:', error);
98 + });
99 +}
100 +
101 +function checkValidServiceWorker(swUrl, config) {
102 + // Check if the service worker can be found. If it can't reload the page.
103 + fetch(swUrl, {
104 + headers: { 'Service-Worker': 'script' },
105 + })
106 + .then(response => {
107 + // Ensure service worker exists, and that we really are getting a JS file.
108 + const contentType = response.headers.get('content-type');
109 + if (
110 + response.status === 404 ||
111 + (contentType != null && contentType.indexOf('javascript') === -1)
112 + ) {
113 + // No service worker found. Probably a different app. Reload the page.
114 + navigator.serviceWorker.ready.then(registration => {
115 + registration.unregister().then(() => {
116 + window.location.reload();
117 + });
118 + });
119 + } else {
120 + // Service worker found. Proceed as normal.
121 + registerValidSW(swUrl, config);
122 + }
123 + })
124 + .catch(() => {
125 + console.log(
126 + 'No internet connection found. App is running in offline mode.'
127 + );
128 + });
129 +}
130 +
131 +export function unregister() {
132 + if ('serviceWorker' in navigator) {
133 + navigator.serviceWorker.ready
134 + .then(registration => {
135 + registration.unregister();
136 + })
137 + .catch(error => {
138 + console.error(error.message);
139 + });
140 + }
141 +}
1 +// jest-dom adds custom jest matchers for asserting on DOM nodes.
2 +// allows you to do things like:
3 +// expect(element).toHaveTextContent(/react/i)
4 +// learn more: https://github.com/testing-library/jest-dom
5 +import '@testing-library/jest-dom/extend-expect';
This diff could not be displayed because it is too large.
1 +{
2 + "parser": "babel-eslint",
3 + "env": {
4 + "commonjs": true,
5 + "es6": true,
6 + "node": true
7 + },
8 + "extends": "eslint:recommended",
9 + "globals": {
10 + "Atomics": "readonly",
11 + "SharedArrayBuffer": "readonly"
12 + },
13 + "parserOptions": {
14 + "ecmaVersion": 11
15 + },
16 + "rules": {}
17 +}
1 +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 +
3 +# dotenv
4 +.env
5 +
6 +#access.log
7 +access.log
8 +
9 +# dependencies
10 +/node_modules
1 +# Jaksimsamil API Documentation
2 +
3 +## Overview
4 +
5 +- TBA
6 +
7 +## URL
8 +
9 +- TBA
10 +
11 +## Usage
12 +
13 +- TBA
14 +
15 +## Example
16 +
17 +- TBA
18 +
19 +## API Table
20 +
21 +| group | description | method | URL | Detail | Auth |
22 +| ------- | --------------------------------- | ------ | ----------------------- | -------- | --------- |
23 +| user | 유저 등록 | POST | api/user | 바로가기 | JWT Token |
24 +| user | 유저 삭제 | DELETE | api/user:id | 바로가기 | JWT Token |
25 +| user | 특정 유저 조회 | GET | api/user:id | 바로가기 | None |
26 +| user | 전체 유저 조회 | GET | api/user | 바로가기 | JWT Token |
27 +| friend | 유저 친구 등록 | POST | api/friend | 바로가기 | JWT Token |
28 +| friend | 유저의 친구 조회 | GET | api/friend:id | 바로가기 | None |
29 +| profile | 유저가 푼 문제 조회(백준) | GET | api/profile/solvedBJ:id | 바로가기 | None |
30 +| profile | 유저가 푼 문제 동기화(백준) | PATCH | api/profile/syncBJ | 바로가기 | None |
31 +| profile | 유저 정보 수정 | POST | api/profile/setprofile | 바로가기 | JWT TOKEN |
32 +| profile | 유저 정보 받아오기 | POST | api/profile/getprofile | 바로가기 | JWT |
33 +| profile | 추천 문제 조회 | POST | api/profile/recommend | 바로가기 | None |
34 +| notify | 슬랙 메시지 전송 요청 (성취여부) | POST | api/notify/goal | 바로가기 | Jwt Token |
35 +| notify | 슬랙 메시지 전송 요청 (문제 추천) | POST | api/notify/recommend | 바로가기 | None |
36 +| auth | 로그인 | POST | api/auth/login | 바로가기 | None |
37 +| auth | 로그아웃 | POST | api/auth/logout | 바로가기 | JWT Token |
38 +| auth | 회원가입 | POST | api/auth/register | 바로가기 | None |
39 +| auth | 로그인 확인 | GET | api/auth/check | 바로가기 | None |
This diff could not be displayed because it is too large.
1 +const Koa = require("koa");
2 +const Router = require("koa-router");
3 +const bodyParser = require("koa-bodyparser");
4 +const mongoose = require("mongoose");
5 +const fs = require("fs");
6 +const morgan = require("koa-morgan");
7 +const jwtMiddleware = require("./src/lib/jwtMiddleware");
8 +const api = require("./src/api");
9 +
10 +require("dotenv").config();
11 +
12 +const app = new Koa();
13 +const router = new Router();
14 +const accessLogStream = fs.createWriteStream(__dirname + "/access.log", {
15 + flags: "a",
16 +});
17 +require("dotenv").config();
18 +app.use(bodyParser());
19 +app.use(jwtMiddleware);
20 +app.use(morgan("combined", { stream: accessLogStream }));
21 +const { SERVER_PORT, MONGO_URL } = process.env;
22 +
23 +router.use("/api", api.routes());
24 +app.use(router.routes()).use(router.allowedMethods());
25 +
26 +mongoose
27 + .connect(MONGO_URL, {
28 + useNewUrlParser: true,
29 + useFindAndModify: false,
30 + useUnifiedTopology: true,
31 + })
32 + .then(() => {
33 + console.log("Connected to MongoDB");
34 + })
35 + .catch((e) => {
36 + console.log(e);
37 + });
38 +
39 +app.listen(SERVER_PORT, () => {
40 + console.log("Server is running on port", process.env.SERVER_PORT);
41 +});
This diff could not be displayed because it is too large.
1 +{
2 + "name": "jaksimsamil-server",
3 + "version": "1.0.0",
4 + "main": "index.js",
5 + "license": "MIT",
6 + "dependencies": {
7 + "axios": "^0.19.2",
8 + "bcrypt": "^4.0.1",
9 + "body-parser": "^1.19.0",
10 + "cheerio": "^1.0.0-rc.3",
11 + "cookie-parser": "^1.4.5",
12 + "dotenv": "^8.2.0",
13 + "eslint-config-prettier": "^6.11.0",
14 + "fs": "^0.0.1-security",
15 + "iconv": "^3.0.0",
16 + "joi": "^14.3.1",
17 + "jsonwebtoken": "^8.5.1",
18 + "koa": "^2.12.0",
19 + "koa-bodyparser": "^4.3.0",
20 + "koa-morgan": "^1.0.1",
21 + "koa-router": "^9.0.1",
22 + "mongoose": "^5.9.17",
23 + "morgan": "^1.10.0",
24 + "node-schedule": "^1.3.2",
25 + "path": "^0.12.7",
26 + "slack-client": "^2.0.6",
27 + "slack-node": "^0.1.8",
28 + "voca": "^1.4.0"
29 + },
30 + "devDependencies": {
31 + "babel-eslint": "^10.1.0",
32 + "eslint": "^7.1.0",
33 + "nodemon": "^2.0.4"
34 + },
35 + "scripts": {
36 + "start": "node src",
37 + "start:dev": "nodemon --watch src/ src/index.js"
38 + }
39 +}
1 +const Joi = require("joi");
2 +const User = require("../../models/user");
3 +const Profile = require("../../models/profile");
4 +/*
5 +POST /api/auth/register
6 +{
7 + username: 'userid'
8 + password: 'userpassword'
9 +}
10 +*/
11 +exports.register = async (ctx) => {
12 + const schema = Joi.object().keys({
13 + username: Joi.string().alphanum().min(3).max(20).required(),
14 + password: Joi.string().required(),
15 + });
16 +
17 + const result = Joi.validate(ctx.request.body, schema);
18 + if (result.error) {
19 + ctx.status = 400;
20 + ctx.body = result.error;
21 + return;
22 + }
23 +
24 + const { username, password } = ctx.request.body;
25 + try {
26 + const isNameExist = await User.findByUsername(username);
27 + if (isNameExist) {
28 + ctx.status = 409;
29 + return;
30 + }
31 + const profile = new Profile({
32 + username,
33 + });
34 + const user = new User({
35 + username,
36 + });
37 + await user.setPassword(password);
38 + await profile.save();
39 + await user.save();
40 + ctx.body = user.serialize();
41 +
42 + const token = user.generateToken();
43 + ctx.cookies.set("access_token", token, {
44 + //3일동안 유효
45 + maxAge: 1000 * 60 * 60 * 24 * 3,
46 + httpOnly: true,
47 + });
48 + } catch (e) {
49 + ctx.throw(500, e);
50 + }
51 +};
52 +/*
53 +POST /api/auth/login
54 +{
55 + username: 'userid'
56 + password: 'userpassword'
57 +}
58 + */
59 +exports.login = async (ctx) => {
60 + const { username, password } = ctx.request.body;
61 + if (!username || !password) {
62 + ctx.status = 401;
63 + return;
64 + }
65 + try {
66 + const user = await User.findByUsername(username);
67 + if (!user) {
68 + ctx.status = 401;
69 + return;
70 + }
71 + const isPasswordValid = await user.checkPassword(password);
72 + if (!isPasswordValid) {
73 + ctx.status = 401;
74 + return;
75 + }
76 + ctx.body = user.serialize();
77 + const token = user.generateToken();
78 + ctx.cookies.set("access_token", token, {
79 + //7일동안 유효
80 + maxAge: 1000 * 60 * 60 * 24 * 7,
81 + httpOnly: true,
82 + });
83 + } catch (e) {
84 + ctx.throw(500, e);
85 + }
86 +};
87 +/*
88 +GET api/auth/check
89 +*/
90 +exports.check = async (ctx) => {
91 + const { user } = ctx.state;
92 + if (!user) {
93 + ctx.status = 401;
94 + return;
95 + }
96 + ctx.body = user;
97 +};
98 +/*
99 +POST /api/auth/logout
100 +*/
101 +exports.logout = async (ctx) => {
102 + ctx.cookies.set("access_token");
103 + ctx.status = 204;
104 +};
1 +const Router = require("koa-router");
2 +const auth = new Router();
3 +const authCtrl = require("./auth.ctrl");
4 +auth.post("/login", authCtrl.login);
5 +auth.post("/logout", authCtrl.logout);
6 +auth.post("/register", authCtrl.register);
7 +auth.get("/check", authCtrl.check);
8 +
9 +module.exports = auth;
1 +const Router = require("koa-router");
2 +const friend = new Router();
3 +
4 +friend.post("/");
5 +friend.delete("/:id");
6 +friend.get("/:id");
7 +friend.get("");
8 +
9 +module.exports = friend;
1 +const Router = require("koa-router");
2 +const api = new Router();
3 +
4 +const auth = require("./auth");
5 +const friend = require("./friend");
6 +const notify = require("./notify");
7 +const user = require("./user");
8 +const profile = require("./profile");
9 +
10 +api.use("/auth", auth.routes());
11 +api.use("/friend", friend.routes());
12 +api.use("/notify", notify.routes());
13 +api.use("/user", user.routes());
14 +api.use("/profile", profile.routes());
15 +
16 +module.exports = api;
1 +const Router = require("koa-router");
2 +const notify = new Router();
3 +const slackCtrl = require("./slack.ctrl");
4 +notify.post("/slack/goal", slackCtrl.slackGoal);
5 +notify.post("/slack/recommend", slackCtrl.slackRecommend);
6 +
7 +module.exports = notify;
1 +const Profile = require("../../models/profile");
2 +const sendSlack = require("../../util/sendSlack");
3 +const problem_set = require("../../data/problem_set");
4 +const compareBJ = require("../../util/compareBJ");
5 +/*
6 +POST api/notify/slack/goal
7 +{
8 + username: "username"
9 +}
10 +*/
11 +exports.slackGoal = async (ctx) => {
12 + try {
13 + const { username } = ctx.request.body;
14 +
15 + const profile = await Profile.findByUsername(username);
16 + if (!profile) {
17 + ctx.status = 401;
18 + return;
19 + }
20 + let slackURL = profile.getslackURL();
21 + if (!slackURL) {
22 + ctx.status = 401;
23 + return;
24 + }
25 + let goalNum = profile.getgoalNum();
26 + let todayNum = profile.getTodaySovled();
27 + let message = "";
28 + if (goalNum < todayNum) {
29 + message =
30 + "오늘의 목표 " +
31 + goalNum +
32 + "문제 중 " +
33 + todayNum +
34 + "문제를 풀었습니다." +
35 + "\n" +
36 + "잘하셨습니다!";
37 + } else {
38 + message =
39 + "오늘의 목표 " +
40 + goalNum +
41 + "문제 중 " +
42 + todayNum +
43 + "문제를 풀었습니다." +
44 + "\n" +
45 + "분발하세요!";
46 + }
47 +
48 + sendSlack.send(message, slackURL);
49 + } catch (e) {
50 + ctx.throw(500, e);
51 + }
52 +};
53 +
54 +/*
55 +POST api/notify/slack/recommend
56 +{
57 + username: "username"
58 +}
59 +*/
60 +exports.slackRecommend = async (ctx) => {
61 + try {
62 + console.log("1");
63 + const { username } = ctx.request.body;
64 +
65 + const profile = await Profile.findByUsername(username);
66 + if (!profile) {
67 + ctx.status = 401;
68 + return;
69 + }
70 + let slackURL = profile.getslackURL();
71 + if (!slackURL) {
72 + ctx.status = 401;
73 + return;
74 + }
75 + let unsolved_data = compareBJ.compareBJ(
76 + profile.getBJdata(),
77 + problem_set.problem_set
78 + );
79 + let recommendData = compareBJ.randomItem(unsolved_data);
80 +
81 + if (!recommendData) {
82 + ctx.status = 401;
83 + return;
84 + }
85 + let message =
86 + "오늘의 추천 문제는 " +
87 + recommendData.problem_number +
88 + "번 " +
89 + " <https://www.boj.kr/" +
90 + recommendData.problem_number +
91 + "|" +
92 + recommendData.problem_title +
93 + ">" +
94 + " 입니다.";
95 + sendSlack.send(message, slackURL);
96 + } catch (e) {
97 + ctx.throw(500, e);
98 + }
99 +};
1 +const Router = require("koa-router");
2 +const profile = new Router();
3 +const profileCtrl = require("./profile.ctrl");
4 +profile.post("/solved:id");
5 +profile.get("/solvednum:id");
6 +profile.post("/recommend", profileCtrl.recommend);
7 +profile.patch("/syncBJ", profileCtrl.syncBJ);
8 +profile.post("/setprofile", profileCtrl.setProfile);
9 +profile.post("/getprofile", profileCtrl.getProfile);
10 +module.exports = profile;
1 +const Profile = require("../../models/profile");
2 +const mongoose = require("mongoose");
3 +const getBJ = require("../../util/getBJ");
4 +const Joi = require("joi");
5 +const analyzeBJ = require("../../util/analyzeBJ");
6 +const compareBJ = require("../../util/compareBJ");
7 +const problem_set = require("../../data/problem_set");
8 +
9 +const { ObjectId } = mongoose.Types;
10 +
11 +exports.checkObjectId = (ctx, next) => {
12 + const { username } = ctx.request.body;
13 + if (!ObjectId.isValid(username)) {
14 + ctx.status = 400;
15 + return;
16 + }
17 + return next();
18 +};
19 +/*POST /api/profile/getprofile
20 +{
21 + username: "username"
22 +}
23 +*/
24 +exports.getProfile = async (ctx) => {
25 + try {
26 + const { username } = ctx.request.body;
27 + const profile = await Profile.findByUsername(username);
28 + if (!profile) {
29 + ctx.status = 401;
30 + return;
31 + }
32 + ctx.body = profile;
33 + } catch (e) {
34 + ctx.throw(500, e);
35 + }
36 +};
37 +/*
38 +POST /api/proflie/setprofile
39 +{
40 + username: "username",
41 + userBJID: "userBJID",
42 + friendList: [String],
43 +}
44 + */
45 +exports.setProfile = async (ctx) => {
46 + const schema = Joi.object()
47 + .keys({
48 + username: Joi.string(),
49 + userBJID: Joi.string(),
50 + //freindList: Joi.array().items(Joi.string()),
51 + })
52 + .unknown();
53 + console.log(ctx.request.body);
54 + const result = Joi.validate(ctx.request.body, schema);
55 + if (result.error) {
56 + ctx.status = 400;
57 + ctx.body = result.error;
58 + return;
59 + }
60 +
61 + try {
62 + const profile = await Profile.findOneAndUpdate(
63 + { username: ctx.request.body.username },
64 + ctx.request.body,
65 + {
66 + new: true,
67 + }
68 + ).exec();
69 +
70 + if (!profile) {
71 + ctx.status = 404;
72 + return;
73 + }
74 + ctx.body = profile;
75 + } catch (e) {
76 + ctx.throw(500, e);
77 + }
78 +};
79 +/*
80 +PATCH /api/proflie/syncBJ
81 +{
82 + username: 'userid'
83 +}
84 + */
85 +exports.syncBJ = async function (ctx) {
86 + const { username } = ctx.request.body;
87 +
88 + if (!username) {
89 + ctx.status = 401;
90 + return;
91 + }
92 +
93 + try {
94 + const profile = await Profile.findByUsername(username);
95 + if (!profile) {
96 + ctx.status = 401;
97 + return;
98 + }
99 + const BJID = await profile.getBJID();
100 + let BJdata = await getBJ.getBJ(BJID);
101 + let BJdata_date = await analyzeBJ.analyzeBJ(BJdata);
102 + const updateprofile = await Profile.findOneAndUpdate(
103 + { username: username },
104 + { solvedBJ: BJdata, solvedBJ_date: BJdata_date },
105 + { new: true }
106 + ).exec();
107 + ctx.body = updateprofile;
108 + } catch (e) {
109 + ctx.throw(500, e);
110 + }
111 +};
112 +
113 +/*
114 +POST /api/proflie/recommend
115 +{
116 + username: 'userid'
117 +}
118 + */
119 +exports.recommend = async (ctx) => {
120 + const { username } = ctx.request.body;
121 +
122 + if (!username) {
123 + ctx.status = 401;
124 + return;
125 + }
126 + try {
127 + const profile = await Profile.findByUsername(username);
128 + if (!profile) {
129 + ctx.status = 401;
130 + return;
131 + }
132 + let unsolved_data = compareBJ.compareBJ(
133 + profile.getBJdata(),
134 + problem_set.problem_set
135 + );
136 + ctx.body = compareBJ.randomItem(unsolved_data);
137 + //데이터가 비었을 떄 예외처리 필요
138 + } catch (e) {
139 + ctx.throw(500, e);
140 + }
141 +};
1 +const Router = require("koa-router");
2 +const user = new Router();
3 +user.post("/");
4 +user.delete("/:id");
5 +user.get("/:id");
6 +user.get("");
7 +
8 +module.exports = user;
1 +exports.problem_set = [
2 + {
3 + problem_number: "1517",
4 + problem_title: "버블 소트",
5 + solved_date: "20200621",
6 + },
7 + {
8 + problem_number: "2448",
9 + problem_title: "별 찍기 - 11",
10 + solved_date: "20200621",
11 + },
12 + { problem_number: "1891", problem_title: "사분면", solved_date: "20200621" },
13 + { problem_number: "1074", problem_title: "Z", solved_date: "20200620" },
14 + {
15 + problem_number: "2263",
16 + problem_title: "트리의 순회",
17 + solved_date: "20200620",
18 + },
19 + {
20 + problem_number: "1780",
21 + problem_title: "종이의 개수",
22 + solved_date: "20200619",
23 + },
24 + {
25 + problem_number: "11728",
26 + problem_title: "배열 합치기",
27 + solved_date: "20200619",
28 + },
29 + {
30 + problem_number: "10816",
31 + problem_title: "숫자 카드 2",
32 + solved_date: "20200619",
33 + },
34 + {
35 + problem_number: "10815",
36 + problem_title: "숫자 카드",
37 + solved_date: "20200619",
38 + },
39 + {
40 + problem_number: "2109",
41 + problem_title: "순회강연",
42 + solved_date: "20200619",
43 + },
44 + {
45 + problem_number: "1202",
46 + problem_title: "보석 도둑",
47 + solved_date: "20200619",
48 + },
49 + {
50 + problem_number: "1285",
51 + problem_title: "동전 뒤집기",
52 + solved_date: "20200617",
53 + },
54 + {
55 + problem_number: "2138",
56 + problem_title: "전구와 스위치",
57 + solved_date: "20200617",
58 + },
59 + { problem_number: "1080", problem_title: "행렬", solved_date: "20200617" },
60 + { problem_number: "11399", problem_title: "ATM", solved_date: "20200616" },
61 + {
62 + problem_number: "1931",
63 + problem_title: "회의실배정",
64 + solved_date: "20200616",
65 + },
66 + { problem_number: "11047", problem_title: "동전 0", solved_date: "20200615" },
67 + {
68 + problem_number: "15666",
69 + problem_title: "N과 M (12)",
70 + solved_date: "20200614",
71 + },
72 + {
73 + problem_number: "15665",
74 + problem_title: "N과 M (11)",
75 + solved_date: "20200614",
76 + },
77 + {
78 + problem_number: "15664",
79 + problem_title: "N과 M (10)",
80 + solved_date: "20200614",
81 + },
82 + {
83 + problem_number: "15663",
84 + problem_title: "N과 M (9)",
85 + solved_date: "20200614",
86 + },
87 + {
88 + problem_number: "15657",
89 + problem_title: "N과 M (8)",
90 + solved_date: "20200614",
91 + },
92 + {
93 + problem_number: "15656",
94 + problem_title: "N과 M (7)",
95 + solved_date: "20200614",
96 + },
97 + {
98 + problem_number: "15655",
99 + problem_title: "N과 M (6)",
100 + solved_date: "20200614",
101 + },
102 + {
103 + problem_number: "15654",
104 + problem_title: "N과 M (5)",
105 + solved_date: "20200614",
106 + },
107 + {
108 + problem_number: "15652",
109 + problem_title: "N과 M (4)",
110 + solved_date: "20200614",
111 + },
112 + {
113 + problem_number: "15651",
114 + problem_title: "N과 M (3)",
115 + solved_date: "20200612",
116 + },
117 + {
118 + problem_number: "15650",
119 + problem_title: "N과 M (2)",
120 + solved_date: "20200612",
121 + },
122 + {
123 + problem_number: "15649",
124 + problem_title: "N과 M (1)",
125 + solved_date: "20200612",
126 + },
127 + { problem_number: "6603", problem_title: "로또", solved_date: "20200612" },
128 + {
129 + problem_number: "10971",
130 + problem_title: "외판원 순회 2",
131 + solved_date: "20200611",
132 + },
133 + {
134 + problem_number: "10819",
135 + problem_title: "차이를 최대로",
136 + solved_date: "20200611",
137 + },
138 + {
139 + problem_number: "10973",
140 + problem_title: "이전 순열",
141 + solved_date: "20200611",
142 + },
143 + {
144 + problem_number: "10974",
145 + problem_title: "모든 순열",
146 + solved_date: "20200611",
147 + },
148 + {
149 + problem_number: "10972",
150 + problem_title: "다음 순열",
151 + solved_date: "20200611",
152 + },
153 + { problem_number: "7576", problem_title: "토마토", solved_date: "20200608" },
154 + { problem_number: "1248", problem_title: "맞춰봐", solved_date: "20200312" },
155 + { problem_number: "2529", problem_title: "부등호", solved_date: "20200311" },
156 + {
157 + problem_number: "15661",
158 + problem_title: "링크와 스타트",
159 + solved_date: "20200311",
160 + },
161 + { problem_number: "14501", problem_title: "퇴사", solved_date: "20200311" },
162 + {
163 + problem_number: "1759",
164 + problem_title: "암호 만들기",
165 + solved_date: "20200310",
166 + },
167 + {
168 + problem_number: "14391",
169 + problem_title: "종이 조각",
170 + solved_date: "20200306",
171 + },
172 + {
173 + problem_number: "14889",
174 + problem_title: "스타트와 링크",
175 + solved_date: "20200305",
176 + },
177 + {
178 + problem_number: "1182",
179 + problem_title: "부분수열의 합",
180 + solved_date: "20200305",
181 + },
182 + { problem_number: "11723", problem_title: "집합", solved_date: "20200305" },
183 + {
184 + problem_number: "1748",
185 + problem_title: "수 이어 쓰기 1",
186 + solved_date: "20200305",
187 + },
188 + {
189 + problem_number: "6064",
190 + problem_title: "카잉 달력",
191 + solved_date: "20200305",
192 + },
193 + { problem_number: "1107", problem_title: "리모컨", solved_date: "20200305" },
194 + {
195 + problem_number: "3085",
196 + problem_title: "사탕 게임",
197 + solved_date: "20200305",
198 + },
199 + {
200 + problem_number: "2309",
201 + problem_title: "일곱 난쟁이",
202 + solved_date: "20200305",
203 + },
204 + {
205 + problem_number: "1748",
206 + problem_title: "수 이어 쓰기 1",
207 + solved_date: "20200228",
208 + },
209 + {
210 + problem_number: "14500",
211 + problem_title: "테트로미노",
212 + solved_date: "20200228",
213 + },
214 + { problem_number: "1107", problem_title: "리모컨", solved_date: "20200228" },
215 + {
216 + problem_number: "1476",
217 + problem_title: "날짜 계산",
218 + solved_date: "20200228",
219 + },
220 + {
221 + problem_number: "3085",
222 + problem_title: "사탕 게임",
223 + solved_date: "20200228",
224 + },
225 + {
226 + problem_number: "2309",
227 + problem_title: "일곱 난쟁이",
228 + solved_date: "20200228",
229 + },
230 + {
231 + problem_number: "1261",
232 + problem_title: "알고스팟",
233 + solved_date: "20200228",
234 + },
235 + {
236 + problem_number: "13549",
237 + problem_title: "숨바꼭질 3",
238 + solved_date: "20200227",
239 + },
240 + {
241 + problem_number: "14226",
242 + problem_title: "이모티콘",
243 + solved_date: "20200227",
244 + },
245 + {
246 + problem_number: "13913",
247 + problem_title: "숨바꼭질 4",
248 + solved_date: "20200227",
249 + },
250 + {
251 + problem_number: "1697",
252 + problem_title: "숨바꼭질",
253 + solved_date: "20200227",
254 + },
255 + {
256 + problem_number: "1967",
257 + problem_title: "트리의 지름",
258 + solved_date: "20200221",
259 + },
260 + {
261 + problem_number: "1167",
262 + problem_title: "트리의 지름",
263 + solved_date: "20200221",
264 + },
265 + {
266 + problem_number: "11725",
267 + problem_title: "트리의 부모 찾기",
268 + solved_date: "20200221",
269 + },
270 + {
271 + problem_number: "2250",
272 + problem_title: "트리의 높이와 너비",
273 + solved_date: "20200221",
274 + },
275 + {
276 + problem_number: "1991",
277 + problem_title: "트리 순회",
278 + solved_date: "20200221",
279 + },
280 + {
281 + problem_number: "7562",
282 + problem_title: "나이트의 이동",
283 + solved_date: "20200220",
284 + },
285 + {
286 + problem_number: "2178",
287 + problem_title: "미로 탐색",
288 + solved_date: "20200220",
289 + },
290 + {
291 + problem_number: "4963",
292 + problem_title: "섬의 개수",
293 + solved_date: "20200219",
294 + },
295 + {
296 + problem_number: "2667",
297 + problem_title: "단지번호붙이기",
298 + solved_date: "20200219",
299 + },
300 + {
301 + problem_number: "1707",
302 + problem_title: "이분 그래프",
303 + solved_date: "20200217",
304 + },
305 + {
306 + problem_number: "11724",
307 + problem_title: "연결 요소의 개수",
308 + solved_date: "20200214",
309 + },
310 + {
311 + problem_number: "1260",
312 + problem_title: "DFS와 BFS",
313 + solved_date: "20200214",
314 + },
315 + { problem_number: "13023", problem_title: "ABCDE", solved_date: "20200213" },
316 + { problem_number: "11652", problem_title: "카드", solved_date: "20200210" },
317 + {
318 + problem_number: "1377",
319 + problem_title: "버블 소트",
320 + solved_date: "20200210",
321 + },
322 + {
323 + problem_number: "11004",
324 + problem_title: "K번째 수",
325 + solved_date: "20200210",
326 + },
327 + { problem_number: "10825", problem_title: "국영수", solved_date: "20200210" },
328 + {
329 + problem_number: "2751",
330 + problem_title: "수 정렬하기 2",
331 + solved_date: "20200210",
332 + },
333 + {
334 + problem_number: "9461",
335 + problem_title: "파도반 수열",
336 + solved_date: "20200205",
337 + },
338 + {
339 + problem_number: "1699",
340 + problem_title: "제곱수의 합",
341 + solved_date: "20200205",
342 + },
343 + {
344 + problem_number: "9095",
345 + problem_title: "1, 2, 3 더하기",
346 + solved_date: "20200205",
347 + },
348 + { problem_number: "2225", problem_title: "합분해", solved_date: "20200205" },
349 + {
350 + problem_number: "2133",
351 + problem_title: "타일 채우기",
352 + solved_date: "20200204",
353 + },
354 + {
355 + problem_number: "11727",
356 + problem_title: "2×n 타일링 2",
357 + solved_date: "20200203",
358 + },
359 + {
360 + problem_number: "11726",
361 + problem_title: "2×n 타일링",
362 + solved_date: "20200203",
363 + },
364 + {
365 + problem_number: "1463",
366 + problem_title: "1로 만들기",
367 + solved_date: "20200203",
368 + },
369 + {
370 + problem_number: "2748",
371 + problem_title: "피보나치 수 2",
372 + solved_date: "20200203",
373 + },
374 + {
375 + problem_number: "2747",
376 + problem_title: "피보나치 수",
377 + solved_date: "20200203",
378 + },
379 + {
380 + problem_number: "11656",
381 + problem_title: "접미사 배열",
382 + solved_date: "20200203",
383 + },
384 + { problem_number: "10824", problem_title: "네 수", solved_date: "20200203" },
385 + {
386 + problem_number: "2743",
387 + problem_title: "단어 길이 재기",
388 + solved_date: "20200203",
389 + },
390 + {
391 + problem_number: "10820",
392 + problem_title: "문자열 분석",
393 + solved_date: "20200203",
394 + },
395 + {
396 + problem_number: "10808",
397 + problem_title: "알파벳 개수",
398 + solved_date: "20200203",
399 + },
400 + { problem_number: "11655", problem_title: "ROT13", solved_date: "20200203" },
401 + {
402 + problem_number: "11720",
403 + problem_title: "숫자의 합",
404 + solved_date: "20200131",
405 + },
406 + { problem_number: "1008", problem_title: "A/B", solved_date: "20200131" },
407 + {
408 + problem_number: "10951",
409 + problem_title: "A+B - 4",
410 + solved_date: "20200131",
411 + },
412 + {
413 + problem_number: "2557",
414 + problem_title: "Hello World",
415 + solved_date: "20200131",
416 + },
417 + {
418 + problem_number: "1021",
419 + problem_title: "회전하는 큐",
420 + solved_date: "20200131",
421 + },
422 + {
423 + problem_number: "1966",
424 + problem_title: "프린터 큐",
425 + solved_date: "20200131",
426 + },
427 + { problem_number: "2164", problem_title: "카드2", solved_date: "20200131" },
428 + {
429 + problem_number: "10799",
430 + problem_title: "쇠막대기",
431 + solved_date: "20200131",
432 + },
433 + {
434 + problem_number: "17413",
435 + problem_title: "단어 뒤집기 2",
436 + solved_date: "20200131",
437 + },
438 + { problem_number: "10866", problem_title: "덱", solved_date: "20200131" },
439 + {
440 + problem_number: "1158",
441 + problem_title: "요세푸스 문제",
442 + solved_date: "20200131",
443 + },
444 + { problem_number: "10845", problem_title: "큐", solved_date: "20200130" },
445 + { problem_number: "1406", problem_title: "에디터", solved_date: "20200130" },
446 + {
447 + problem_number: "1874",
448 + problem_title: "스택 수열",
449 + solved_date: "20200130",
450 + },
451 + { problem_number: "9012", problem_title: "괄호", solved_date: "20200130" },
452 + {
453 + problem_number: "9093",
454 + problem_title: "단어 뒤집기",
455 + solved_date: "20200130",
456 + },
457 + { problem_number: "10828", problem_title: "스택", solved_date: "20200129" },
458 + {
459 + problem_number: "11721",
460 + problem_title: "열 개씩 끊어 출력하기",
461 + solved_date: "20200126",
462 + },
463 + {
464 + problem_number: "11719",
465 + problem_title: "그대로 출력하기 2",
466 + solved_date: "20200126",
467 + },
468 + {
469 + problem_number: "11718",
470 + problem_title: "그대로 출력하기",
471 + solved_date: "20200126",
472 + },
473 + {
474 + problem_number: "10953",
475 + problem_title: "A+B - 6",
476 + solved_date: "20200126",
477 + },
478 + { problem_number: "2558", problem_title: "A+B - 2", solved_date: "20200126" },
479 + {
480 + problem_number: "10814",
481 + problem_title: "나이순 정렬",
482 + solved_date: "20200123",
483 + },
484 + {
485 + problem_number: "1181",
486 + problem_title: "단어 정렬",
487 + solved_date: "20200122",
488 + },
489 + {
490 + problem_number: "11651",
491 + problem_title: "좌표 정렬하기 2",
492 + solved_date: "20200122",
493 + },
494 + {
495 + problem_number: "11650",
496 + problem_title: "좌표 정렬하기",
497 + solved_date: "20200122",
498 + },
499 + {
500 + problem_number: "1427",
501 + problem_title: "소트인사이드",
502 + solved_date: "20190823",
503 + },
504 + { problem_number: "2108", problem_title: "통계학", solved_date: "20190823" },
505 + {
506 + problem_number: "10989",
507 + problem_title: "수 정렬하기 3",
508 + solved_date: "20190823",
509 + },
510 + {
511 + problem_number: "2751",
512 + problem_title: "수 정렬하기 2",
513 + solved_date: "20190814",
514 + },
515 + {
516 + problem_number: "2750",
517 + problem_title: "수 정렬하기",
518 + solved_date: "20190814",
519 + },
520 + {
521 + problem_number: "1436",
522 + problem_title: "영화감독 숌",
523 + solved_date: "20190814",
524 + },
525 + {
526 + problem_number: "1018",
527 + problem_title: "체스판 다시 칠하기",
528 + solved_date: "20190814",
529 + },
530 + { problem_number: "7568", problem_title: "덩치", solved_date: "20190814" },
531 + { problem_number: "2231", problem_title: "분해합", solved_date: "20190814" },
532 + { problem_number: "2798", problem_title: "블랙잭", solved_date: "20190814" },
533 + { problem_number: "1002", problem_title: "터렛", solved_date: "20190814" },
534 + {
535 + problem_number: "3053",
536 + problem_title: "택시 기하학",
537 + solved_date: "20190814",
538 + },
539 + {
540 + problem_number: "4153",
541 + problem_title: "직각삼각형",
542 + solved_date: "20190814",
543 + },
544 + {
545 + problem_number: "3009",
546 + problem_title: "네 번째 점",
547 + solved_date: "20190814",
548 + },
549 + {
550 + problem_number: "1085",
551 + problem_title: "직사각형에서 탈출",
552 + solved_date: "20190814",
553 + },
554 + {
555 + problem_number: "9020",
556 + problem_title: "골드바흐의 추측",
557 + solved_date: "20190814",
558 + },
559 + {
560 + problem_number: "4948",
561 + problem_title: "베르트랑 공준",
562 + solved_date: "20190814",
563 + },
564 + {
565 + problem_number: "1929",
566 + problem_title: "소수 구하기",
567 + solved_date: "20190814",
568 + },
569 + { problem_number: "2581", problem_title: "소수", solved_date: "20190811" },
570 + {
571 + problem_number: "1978",
572 + problem_title: "소수 찾기",
573 + solved_date: "20190811",
574 + },
575 + { problem_number: "2292", problem_title: "벌집", solved_date: "20190811" },
576 + {
577 + problem_number: "6064",
578 + problem_title: "카잉 달력",
579 + solved_date: "20190811",
580 + },
581 + {
582 + problem_number: "2775",
583 + problem_title: "부녀회장이 될테야",
584 + solved_date: "20190811",
585 + },
586 + {
587 + problem_number: "10250",
588 + problem_title: "ACM 호텔",
589 + solved_date: "20190811",
590 + },
591 + {
592 + problem_number: "2869",
593 + problem_title: "달팽이는 올라가고 싶다",
594 + solved_date: "20190811",
595 + },
596 + {
597 + problem_number: "1011",
598 + problem_title: "Fly me to the Alpha Centauri",
599 + solved_date: "20190811",
600 + },
601 + {
602 + problem_number: "1193",
603 + problem_title: "분수찾기",
604 + solved_date: "20190810",
605 + },
606 + {
607 + problem_number: "2839",
608 + problem_title: "설탕 배달",
609 + solved_date: "20190809",
610 + },
611 + {
612 + problem_number: "1712",
613 + problem_title: "손익분기점",
614 + solved_date: "20190809",
615 + },
616 + {
617 + problem_number: "1316",
618 + problem_title: "그룹 단어 체커",
619 + solved_date: "20190809",
620 + },
621 + {
622 + problem_number: "2941",
623 + problem_title: "크로아티아 알파벳",
624 + solved_date: "20190809",
625 + },
626 + { problem_number: "5622", problem_title: "다이얼", solved_date: "20190809" },
627 + { problem_number: "2908", problem_title: "상수", solved_date: "20190809" },
628 + {
629 + problem_number: "1152",
630 + problem_title: "단어의 개수",
631 + solved_date: "20190809",
632 + },
633 + {
634 + problem_number: "1157",
635 + problem_title: "단어 공부",
636 + solved_date: "20190809",
637 + },
638 + {
639 + problem_number: "2675",
640 + problem_title: "문자열 반복",
641 + solved_date: "20190809",
642 + },
643 + {
644 + problem_number: "10809",
645 + problem_title: "알파벳 찾기",
646 + solved_date: "20190809",
647 + },
648 + {
649 + problem_number: "11720",
650 + problem_title: "숫자의 합",
651 + solved_date: "20190809",
652 + },
653 + {
654 + problem_number: "11654",
655 + problem_title: "아스키 코드",
656 + solved_date: "20190809",
657 + },
658 + {
659 + problem_number: "11729",
660 + problem_title: "하노이 탑 이동 순서",
661 + solved_date: "20190809",
662 + },
663 + {
664 + problem_number: "2447",
665 + problem_title: "별 찍기 - 10",
666 + solved_date: "20190809",
667 + },
668 + { problem_number: "3052", problem_title: "나머지", solved_date: "20190807" },
669 + {
670 + problem_number: "10818",
671 + problem_title: "최소, 최대",
672 + solved_date: "20190807",
673 + },
674 + {
675 + problem_number: "10872",
676 + problem_title: "팩토리얼",
677 + solved_date: "20190628",
678 + },
679 + {
680 + problem_number: "10870",
681 + problem_title: "피보나치 수 5",
682 + solved_date: "20190628",
683 + },
684 + { problem_number: "1065", problem_title: "한수", solved_date: "20190628" },
685 + {
686 + problem_number: "4673",
687 + problem_title: "셀프 넘버",
688 + solved_date: "20190628",
689 + },
690 + {
691 + problem_number: "15596",
692 + problem_title: "정수 N개의 합",
693 + solved_date: "20190628",
694 + },
695 + {
696 + problem_number: "4344",
697 + problem_title: "평균은 넘겠지",
698 + solved_date: "20190628",
699 + },
700 + { problem_number: "2920", problem_title: "음계", solved_date: "20190628" },
701 + { problem_number: "8958", problem_title: "OX퀴즈", solved_date: "20190628" },
702 + { problem_number: "1546", problem_title: "평균", solved_date: "20190628" },
703 + {
704 + problem_number: "2577",
705 + problem_title: "숫자의 개수",
706 + solved_date: "20190628",
707 + },
708 + { problem_number: "2562", problem_title: "최댓값", solved_date: "20190628" },
709 + {
710 + problem_number: "1110",
711 + problem_title: "더하기 사이클",
712 + solved_date: "20190628",
713 + },
714 + {
715 + problem_number: "10951",
716 + problem_title: "A+B - 4",
717 + solved_date: "20190628",
718 + },
719 + {
720 + problem_number: "10952",
721 + problem_title: "A+B - 5",
722 + solved_date: "20190628",
723 + },
724 + {
725 + problem_number: "10871",
726 + problem_title: "X보다 작은 수",
727 + solved_date: "20190628",
728 + },
729 + {
730 + problem_number: "2439",
731 + problem_title: "별 찍기 - 2",
732 + solved_date: "20190628",
733 + },
734 + {
735 + problem_number: "2438",
736 + problem_title: "별 찍기 - 1",
737 + solved_date: "20190628",
738 + },
739 + {
740 + problem_number: "11022",
741 + problem_title: "A+B - 8",
742 + solved_date: "20190628",
743 + },
744 + {
745 + problem_number: "11021",
746 + problem_title: "A+B - 7",
747 + solved_date: "20190628",
748 + },
749 + { problem_number: "2742", problem_title: "기찍 N", solved_date: "20190628" },
750 + { problem_number: "2741", problem_title: "N 찍기", solved_date: "20190628" },
751 + {
752 + problem_number: "15552",
753 + problem_title: "빠른 A+B",
754 + solved_date: "20190628",
755 + },
756 + { problem_number: "8393", problem_title: "합", solved_date: "20190628" },
757 + {
758 + problem_number: "10950",
759 + problem_title: "A+B - 3",
760 + solved_date: "20190628",
761 + },
762 + { problem_number: "2739", problem_title: "구구단", solved_date: "20190628" },
763 + { problem_number: "10817", problem_title: "세 수", solved_date: "20190627" },
764 + {
765 + problem_number: "2884",
766 + problem_title: "알람 시계",
767 + solved_date: "20190627",
768 + },
769 + { problem_number: "2753", problem_title: "윤년", solved_date: "20190627" },
770 + {
771 + problem_number: "9498",
772 + problem_title: "시험 성적",
773 + solved_date: "20190627",
774 + },
775 + {
776 + problem_number: "1330",
777 + problem_title: "두 수 비교하기",
778 + solved_date: "20190627",
779 + },
780 + { problem_number: "2588", problem_title: "곱셈", solved_date: "20190627" },
781 + { problem_number: "10430", problem_title: "나머지", solved_date: "20190627" },
782 + {
783 + problem_number: "10869",
784 + problem_title: "사칙연산",
785 + solved_date: "20190627",
786 + },
787 + { problem_number: "1008", problem_title: "A/B", solved_date: "20190627" },
788 + { problem_number: "10998", problem_title: "A×B", solved_date: "20190627" },
789 + { problem_number: "7287", problem_title: "등록", solved_date: "20190627" },
790 + { problem_number: "10172", problem_title: "개", solved_date: "20190627" },
791 + { problem_number: "10171", problem_title: "고양이", solved_date: "20190627" },
792 + {
793 + problem_number: "10718",
794 + problem_title: "We love kriii",
795 + solved_date: "20190627",
796 + },
797 + { problem_number: "1001", problem_title: "A-B", solved_date: "20190607" },
798 + { problem_number: "1000", problem_title: "A+B", solved_date: "20190607" },
799 + {
800 + problem_number: "2557",
801 + problem_title: "Hello World",
802 + solved_date: "20190607",
803 + },
804 +];
1 +const jwt = require("jsonwebtoken");
2 +const User = require("../models/user");
3 +
4 +const jwtMiddleware = async (ctx, next) => {
5 + const token = ctx.cookies.get("access_token");
6 +
7 + if (!token) {
8 + return next();
9 + }
10 + try {
11 + const decoded = jwt.verify(token, process.env.JWT_SECRET);
12 + ctx.state.user = {
13 + _id: decoded._id,
14 + username: decoded.username,
15 + };
16 + const now = Math.floor(Date.now() / 1000);
17 + if (decoded.exp - now < 60 * 60 * 24 * 3.5) {
18 + const user = await User.findById(decoded._id);
19 + const token = user.generateToken();
20 + ctx.cookies.set("access_token", token, {
21 + maxAge: 1000 * 60 * 60 * 24 * 7, //7days
22 + httpOnly: true,
23 + });
24 + }
25 +
26 + return next();
27 + } catch (e) {
28 + return next();
29 + }
30 +};
31 +module.exports = jwtMiddleware;
1 +const mongoose = require("mongoose");
2 +
3 +const { Schema } = mongoose;
4 +
5 +const ProfileSchema = new Schema({
6 + username: { type: String, required: true, unique: true },
7 + userBJID: String,
8 + solvedBJ: Object,
9 + solvedBJ_date: Object,
10 + friendList: [String],
11 + slackWebHookURL: String,
12 + goalNum: Number,
13 +});
14 +ProfileSchema.statics.findByUsername = function (username) {
15 + return this.findOne({ username });
16 +};
17 +ProfileSchema.methods.getBJID = function () {
18 + return this.userBJID;
19 +};
20 +ProfileSchema.methods.getBJdata = function () {
21 + return this.solvedBJ;
22 +};
23 +ProfileSchema.methods.getslackURL = function () {
24 + return this.slackWebHookURL;
25 +};
26 +ProfileSchema.methods.getgoalNum = function () {
27 + return this.goalNum;
28 +};
29 +ProfileSchema.methods.getTodaySovled = function () {
30 + if (this.solvedBJ_date) {
31 + return this.solvedBJ_date.presentNum;
32 + }
33 +};
34 +
35 +ProfileSchema.methods.serialize = function () {
36 + const data = this.toJSON();
37 + return data;
38 +};
39 +const Profile = mongoose.model("Profile", ProfileSchema);
40 +module.exports = Profile;
1 +const mongoose = require("mongoose");
2 +const bcrypt = require("bcrypt");
3 +const jwt = require("jsonwebtoken");
4 +
5 +const Schema = mongoose.Schema;
6 +
7 +const UserSchema = new Schema({
8 + username: String,
9 + hashedPassword: String,
10 +});
11 +
12 +UserSchema.methods.setPassword = async function (password) {
13 + const hash = await bcrypt.hash(password, 10);
14 + this.hashedPassword = hash;
15 +};
16 +UserSchema.methods.checkPassword = async function (password) {
17 + const result = await bcrypt.compare(password, this.hashedPassword);
18 + return result;
19 +};
20 +UserSchema.statics.findByUsername = function (username) {
21 + return this.findOne({ username });
22 +};
23 +UserSchema.methods.serialize = function () {
24 + const data = this.toJSON();
25 + delete data.hashedPassword;
26 + return data;
27 +};
28 +UserSchema.methods.generateToken = function () {
29 + const token = jwt.sign(
30 + {
31 + _id: this.id,
32 + username: this.username,
33 + },
34 + process.env.JWT_SECRET,
35 + {
36 + expiresIn: "7d",
37 + }
38 + );
39 + return token;
40 +};
41 +const User = mongoose.model("User", UserSchema);
42 +module.exports = User;
1 +exports.StringToDate_BJ = function (date_str) {
2 + let arr_date = date_str.split(" "); //yyyy m dd tt MM SS Fomat LIST
3 + let arr_date_r = arr_date.map(function (str) {
4 + let str_r = str.slice(0, -1);
5 +
6 + return str_r.length == 1 ? "0" + str_r : str_r;
7 + });
8 +
9 + return arr_date_r[0] + arr_date_r[1] + arr_date_r[2]; //YYYYMMDD 형식으로 반환
10 +};
1 +let moment = require("moment");
2 +const problem_set = require("../data/problem_set");
3 +const compareBJ = require("./compareBJ");
4 +exports.analyzeBJ = function (solvedBJ) {
5 + try {
6 + if (solvedBJ) {
7 + let presentDate = moment();
8 + let presentDate_str = presentDate.format("YYYYMMDD");
9 + let latestDate = moment(solvedBJ[0].solved_date, "YYYYMMDD");
10 + let difflatest = presentDate.diff(latestDate, "days");
11 + let latestSolve = solvedBJ[0];
12 +
13 + let solvedBJbyDATE = {};
14 + for (let i = 0; i < solvedBJ.length; i++) {
15 + if (!(solvedBJ[i].solved_date in solvedBJbyDATE)) {
16 + solvedBJbyDATE[solvedBJ[i].solved_date] = [];
17 + solvedBJbyDATE[solvedBJ[i].solved_date].push(solvedBJ[i]);
18 + } else {
19 + solvedBJbyDATE[solvedBJ[i].solved_date].push(solvedBJ[i]);
20 + }
21 + }
22 +
23 + let latestNum = solvedBJbyDATE[solvedBJ[0].solved_date].length;
24 + let presentNum =
25 + presentDate_str in solvedBJbyDATE
26 + ? solvedBJbyDATE[presentDate_str].length
27 + : 0;
28 +
29 + let weekNUM = 0;
30 + let monthNUM = 0;
31 + let totalNUM = 0;
32 + for (let i = 0; i < solvedBJ.length; i++) {
33 + let diffDate = presentDate.diff(
34 + moment(solvedBJ[i].solved_date, "YYYYMMDD"),
35 + "days"
36 + );
37 + if (diffDate <= 7) {
38 + weekNUM++;
39 + monthNUM++;
40 + totalNUM++;
41 + } else if (diffDate <= 31) {
42 + monthNUM++;
43 + totalNUM++;
44 + } else {
45 + totalNUM++;
46 + }
47 + }
48 +
49 + let unsolved_data = compareBJ.compareBJ(
50 + solvedBJ,
51 + problem_set.problem_set
52 + );
53 + let recommend_data = compareBJ.randomItem(unsolved_data);
54 +
55 + let returnOBJ = {
56 + latestDate: latestDate.format("YYYYMMDD"),
57 + difflatest: difflatest,
58 + latestNum: latestNum,
59 + presentNum: presentNum,
60 + weekNum: weekNUM,
61 + monthNum: monthNUM,
62 + totalNum: totalNUM,
63 + solvedBJbyDATE: solvedBJbyDATE,
64 + latestSolve: latestSolve,
65 + recommend_data: recommend_data,
66 + };
67 +
68 + return returnOBJ;
69 + }
70 + } catch (e) {
71 + console.log(e);
72 + }
73 +};
1 +exports.compareBJ = function (solvedBJ_new, problem_set) {
2 + try {
3 + let new_obj = [];
4 +
5 + for (let i = 0; i < problem_set.length; i++) {
6 + let found = false;
7 + for (let j = 0; j < solvedBJ_new.length; j++) {
8 + if (solvedBJ_new[j].problem_number == problem_set[i].problem_number) {
9 + found = true;
10 + break;
11 + }
12 + }
13 + if (!found) {
14 + new_obj.push(problem_set[i]);
15 + }
16 + }
17 + return new_obj;
18 + } catch (e) {
19 + console.log(e);
20 + }
21 +};
22 +
23 +exports.randomItem = function (a) {
24 + return a[Math.floor(Math.random() * a.length)];
25 +};
1 +const axios = require("axios");
2 +const cheerio = require("cheerio");
3 +const StringToDate = require("./StringToDate");
4 +/*
5 +ToDO
6 +- 예외 처리
7 +*/
8 +exports.getBJ = async function (userid) {
9 + let data_list = [];
10 + let next_page_link = "";
11 +
12 + await getStartPage(userid).then((html) => {
13 + //시작 페이지를 가져온다.
14 + //같은 객체를 두번 선언한다. 퍼포먼스에 문제 생길수도
15 + //함수에 객체를 넘기는 방법도 있다.
16 + //첫 페이지 가져온다.
17 + data_list.push(getData(html));
18 + next_page_link = getNextPageLink(html);
19 + });
20 + while (next_page_link != -1) {
21 + //다음 페이지를 가져온다.
22 + await getNextPage(next_page_link).then((html) => {
23 + data_list.push(getData(html));
24 + next_page_link = getNextPageLink(html);
25 + });
26 + }
27 + return data_list.flat(1);
28 +};
29 +
30 +const getStartPage = async (userid) => {
31 + //유저 아이디 입력
32 + try {
33 + return await axios.get(
34 + "https://www.acmicpc.net/status?user_id=" + userid + "&result_id=4"
35 + );
36 + } catch (error) {
37 + console.log(error);
38 + }
39 +};
40 +
41 +const getNextPage = async (link) => {
42 + //링크 입력
43 + try {
44 + return await axios.get(link);
45 + } catch (error) {
46 + console.log(error);
47 + }
48 +};
49 +
50 +const getData = (html) => {
51 + //페이지 데이터 파싱
52 + let psArr = [];
53 + const $ = cheerio.load(html.data);
54 + const $bodyList = $("#status-table > tbody");
55 + $bodyList.children().each((index, element) => {
56 + psArr.push({
57 + problem_number: $(element).find("a.problem_title").text(),
58 + problem_title: $(element).find("a.problem_title").attr("title"),
59 + solved_date: StringToDate.StringToDate_BJ(
60 + $(element).find("a.real-time-update").attr("title")
61 + ),
62 + });
63 + });
64 + return psArr;
65 +};
66 +const getNextPageLink = (html) => {
67 + //다음 페이지가 있으면 다음 페이지 주소 return, 없으면 -1 return
68 + const $ = cheerio.load(html.data);
69 + return $("#next_page").attr("href")
70 + ? "https://www.acmicpc.net/" + $("#next_page").attr("href")
71 + : -1;
72 +};
1 +const Slack = require("slack-node"); // 슬랙 모듈 사용
2 +
3 +/*
4 +const webhookUri =
5 + "https://hooks.slack.com/services/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"; // Webhook URL
6 +*/
7 +
8 +exports.send = async (message, webhookUri) => {
9 + const slack = new Slack();
10 + slack.setWebhook(webhookUri);
11 + slack.webhook(
12 + {
13 + text: message,
14 + },
15 + function (err, response) {
16 + console.log(response);
17 + }
18 + );
19 +};
1 +var getBJ = require("./getBJ");
2 +var fs = require("fs");
3 +
4 +const test = async (userid) => {
5 + let lst = await getBJ.getBJ(userid);
6 + let return_lst = [];
7 + for (let i = 0; i < lst.length; i++) {
8 + return_lst.push(lst[i].problem_number);
9 + }
10 +
11 + var stringJson = JSON.stringify(lst) + "\n";
12 + fs.open("test.json", "a", "666", function (err, id) {
13 + if (err) {
14 + console.log("file open err!!");
15 + } else {
16 + fs.write(id, stringJson, null, "utf8", function (err) {
17 + console.log("file was saved!");
18 + });
19 + }
20 + });
21 +};
22 +
23 +/*
24 +
25 +*/
26 +test("jwseo001");
1 +[
2 + "1517",
3 + "2448",
4 + "1891",
5 + "1074",
6 + "2263",
7 + "1780",
8 + "11728",
9 + "10816",
10 + "10815",
11 + "2109",
12 + "1202",
13 + "1285",
14 + "2138",
15 + "1080",
16 + "11399",
17 + "1931",
18 + "11047",
19 + "15666",
20 + "15665",
21 + "15664",
22 + "15663",
23 + "15657",
24 + "15656",
25 + "15655",
26 + "15654",
27 + "15652",
28 + "15651",
29 + "15650",
30 + "15649",
31 + "6603",
32 + "10971",
33 + "10819",
34 + "10973",
35 + "10974",
36 + "10972",
37 + "7576",
38 + "1248",
39 + "2529",
40 + "15661",
41 + "14501",
42 + "1759",
43 + "14391",
44 + "14889",
45 + "1182",
46 + "11723",
47 + "1748",
48 + "6064",
49 + "1107",
50 + "3085",
51 + "2309",
52 + "1748",
53 + "14500",
54 + "1107",
55 + "1476",
56 + "3085",
57 + "2309",
58 + "1261",
59 + "13549",
60 + "14226",
61 + "13913",
62 + "1697",
63 + "1967",
64 + "1167",
65 + "11725",
66 + "2250",
67 + "1991",
68 + "7562",
69 + "2178",
70 + "4963",
71 + "2667",
72 + "1707",
73 + "11724",
74 + "1260",
75 + "13023",
76 + "11652",
77 + "1377",
78 + "11004",
79 + "10825",
80 + "2751",
81 + "9461",
82 + "1699",
83 + "9095",
84 + "2225",
85 + "2133",
86 + "11727",
87 + "11726",
88 + "1463",
89 + "2748",
90 + "2747",
91 + "11656",
92 + "10824",
93 + "2743",
94 + "10820",
95 + "10808",
96 + "11655",
97 + "11720",
98 + "1008",
99 + "10951",
100 + "2557",
101 + "1021",
102 + "1966",
103 + "2164",
104 + "10799",
105 + "17413",
106 + "10866",
107 + "1158",
108 + "10845",
109 + "1406",
110 + "1874",
111 + "9012",
112 + "9093",
113 + "10828",
114 + "11721",
115 + "11719",
116 + "11718",
117 + "10953",
118 + "2558",
119 + "10814",
120 + "1181",
121 + "11651",
122 + "11650",
123 + "1427",
124 + "2108",
125 + "10989",
126 + "2751",
127 + "2750",
128 + "1436",
129 + "1018",
130 + "7568",
131 + "2231",
132 + "2798",
133 + "1002",
134 + "3053",
135 + "4153",
136 + "3009",
137 + "1085",
138 + "9020",
139 + "4948",
140 + "1929",
141 + "2581",
142 + "1978",
143 + "2292",
144 + "6064",
145 + "2775",
146 + "10250",
147 + "2869",
148 + "1011",
149 + "1193",
150 + "2839",
151 + "1712",
152 + "1316",
153 + "2941",
154 + "5622",
155 + "2908",
156 + "1152",
157 + "1157",
158 + "2675",
159 + "10809",
160 + "11720",
161 + "11654",
162 + "11729",
163 + "2447",
164 + "3052",
165 + "10818",
166 + "10872",
167 + "10870",
168 + "1065",
169 + "4673",
170 + "15596",
171 + "4344",
172 + "2920",
173 + "8958",
174 + "1546",
175 + "2577",
176 + "2562",
177 + "1110",
178 + "10951",
179 + "10952",
180 + "10871",
181 + "2439",
182 + "2438",
183 + "11022",
184 + "11021",
185 + "2742",
186 + "2741",
187 + "15552",
188 + "8393",
189 + "10950",
190 + "2739",
191 + "10817",
192 + "2884",
193 + "2753",
194 + "9498",
195 + "1330",
196 + "2588",
197 + "10430",
198 + "10869",
199 + "1008",
200 + "10998",
201 + "7287",
202 + "10172",
203 + "10171",
204 + "10718",
205 + "1001",
206 + "1000",
207 + "2557"
208 +]
209 +[{"problem_number":"1517","problem_title":"버블 소트","solved_date":"20200621"},{"problem_number":"2448","problem_title":"별 찍기 - 11","solved_date":"20200621"},{"problem_number":"1891","problem_title":"사분면","solved_date":"20200621"},{"problem_number":"1074","problem_title":"Z","solved_date":"20200620"},{"problem_number":"2263","problem_title":"트리의 순회","solved_date":"20200620"},{"problem_number":"1780","problem_title":"종이의 개수","solved_date":"20200619"},{"problem_number":"11728","problem_title":"배열 합치기","solved_date":"20200619"},{"problem_number":"10816","problem_title":"숫자 카드 2","solved_date":"20200619"},{"problem_number":"10815","problem_title":"숫자 카드","solved_date":"20200619"},{"problem_number":"2109","problem_title":"순회강연","solved_date":"20200619"},{"problem_number":"1202","problem_title":"보석 도둑","solved_date":"20200619"},{"problem_number":"1285","problem_title":"동전 뒤집기","solved_date":"20200617"},{"problem_number":"2138","problem_title":"전구와 스위치","solved_date":"20200617"},{"problem_number":"1080","problem_title":"행렬","solved_date":"20200617"},{"problem_number":"11399","problem_title":"ATM","solved_date":"20200616"},{"problem_number":"1931","problem_title":"회의실배정","solved_date":"20200616"},{"problem_number":"11047","problem_title":"동전 0","solved_date":"20200615"},{"problem_number":"15666","problem_title":"N과 M (12)","solved_date":"20200614"},{"problem_number":"15665","problem_title":"N과 M (11)","solved_date":"20200614"},{"problem_number":"15664","problem_title":"N과 M (10)","solved_date":"20200614"},{"problem_number":"15663","problem_title":"N과 M (9)","solved_date":"20200614"},{"problem_number":"15657","problem_title":"N과 M (8)","solved_date":"20200614"},{"problem_number":"15656","problem_title":"N과 M (7)","solved_date":"20200614"},{"problem_number":"15655","problem_title":"N과 M (6)","solved_date":"20200614"},{"problem_number":"15654","problem_title":"N과 M (5)","solved_date":"20200614"},{"problem_number":"15652","problem_title":"N과 M (4)","solved_date":"20200614"},{"problem_number":"15651","problem_title":"N과 M (3)","solved_date":"20200612"},{"problem_number":"15650","problem_title":"N과 M (2)","solved_date":"20200612"},{"problem_number":"15649","problem_title":"N과 M (1)","solved_date":"20200612"},{"problem_number":"6603","problem_title":"로또","solved_date":"20200612"},{"problem_number":"10971","problem_title":"외판원 순회 2","solved_date":"20200611"},{"problem_number":"10819","problem_title":"차이를 최대로","solved_date":"20200611"},{"problem_number":"10973","problem_title":"이전 순열","solved_date":"20200611"},{"problem_number":"10974","problem_title":"모든 순열","solved_date":"20200611"},{"problem_number":"10972","problem_title":"다음 순열","solved_date":"20200611"},{"problem_number":"7576","problem_title":"토마토","solved_date":"20200608"},{"problem_number":"1248","problem_title":"맞춰봐","solved_date":"20200312"},{"problem_number":"2529","problem_title":"부등호","solved_date":"20200311"},{"problem_number":"15661","problem_title":"링크와 스타트","solved_date":"20200311"},{"problem_number":"14501","problem_title":"퇴사","solved_date":"20200311"},{"problem_number":"1759","problem_title":"암호 만들기","solved_date":"20200310"},{"problem_number":"14391","problem_title":"종이 조각","solved_date":"20200306"},{"problem_number":"14889","problem_title":"스타트와 링크","solved_date":"20200305"},{"problem_number":"1182","problem_title":"부분수열의 합","solved_date":"20200305"},{"problem_number":"11723","problem_title":"집합","solved_date":"20200305"},{"problem_number":"1748","problem_title":"수 이어 쓰기 1","solved_date":"20200305"},{"problem_number":"6064","problem_title":"카잉 달력","solved_date":"20200305"},{"problem_number":"1107","problem_title":"리모컨","solved_date":"20200305"},{"problem_number":"3085","problem_title":"사탕 게임","solved_date":"20200305"},{"problem_number":"2309","problem_title":"일곱 난쟁이","solved_date":"20200305"},{"problem_number":"1748","problem_title":"수 이어 쓰기 1","solved_date":"20200228"},{"problem_number":"14500","problem_title":"테트로미노","solved_date":"20200228"},{"problem_number":"1107","problem_title":"리모컨","solved_date":"20200228"},{"problem_number":"1476","problem_title":"날짜 계산","solved_date":"20200228"},{"problem_number":"3085","problem_title":"사탕 게임","solved_date":"20200228"},{"problem_number":"2309","problem_title":"일곱 난쟁이","solved_date":"20200228"},{"problem_number":"1261","problem_title":"알고스팟","solved_date":"20200228"},{"problem_number":"13549","problem_title":"숨바꼭질 3","solved_date":"20200227"},{"problem_number":"14226","problem_title":"이모티콘","solved_date":"20200227"},{"problem_number":"13913","problem_title":"숨바꼭질 4","solved_date":"20200227"},{"problem_number":"1697","problem_title":"숨바꼭질","solved_date":"20200227"},{"problem_number":"1967","problem_title":"트리의 지름","solved_date":"20200221"},{"problem_number":"1167","problem_title":"트리의 지름","solved_date":"20200221"},{"problem_number":"11725","problem_title":"트리의 부모 찾기","solved_date":"20200221"},{"problem_number":"2250","problem_title":"트리의 높이와 너비","solved_date":"20200221"},{"problem_number":"1991","problem_title":"트리 순회","solved_date":"20200221"},{"problem_number":"7562","problem_title":"나이트의 이동","solved_date":"20200220"},{"problem_number":"2178","problem_title":"미로 탐색","solved_date":"20200220"},{"problem_number":"4963","problem_title":"섬의 개수","solved_date":"20200219"},{"problem_number":"2667","problem_title":"단지번호붙이기","solved_date":"20200219"},{"problem_number":"1707","problem_title":"이분 그래프","solved_date":"20200217"},{"problem_number":"11724","problem_title":"연결 요소의 개수","solved_date":"20200214"},{"problem_number":"1260","problem_title":"DFS와 BFS","solved_date":"20200214"},{"problem_number":"13023","problem_title":"ABCDE","solved_date":"20200213"},{"problem_number":"11652","problem_title":"카드","solved_date":"20200210"},{"problem_number":"1377","problem_title":"버블 소트","solved_date":"20200210"},{"problem_number":"11004","problem_title":"K번째 수","solved_date":"20200210"},{"problem_number":"10825","problem_title":"국영수","solved_date":"20200210"},{"problem_number":"2751","problem_title":"수 정렬하기 2","solved_date":"20200210"},{"problem_number":"9461","problem_title":"파도반 수열","solved_date":"20200205"},{"problem_number":"1699","problem_title":"제곱수의 합","solved_date":"20200205"},{"problem_number":"9095","problem_title":"1, 2, 3 더하기","solved_date":"20200205"},{"problem_number":"2225","problem_title":"합분해","solved_date":"20200205"},{"problem_number":"2133","problem_title":"타일 채우기","solved_date":"20200204"},{"problem_number":"11727","problem_title":"2×n 타일링 2","solved_date":"20200203"},{"problem_number":"11726","problem_title":"2×n 타일링","solved_date":"20200203"},{"problem_number":"1463","problem_title":"1로 만들기","solved_date":"20200203"},{"problem_number":"2748","problem_title":"피보나치 수 2","solved_date":"20200203"},{"problem_number":"2747","problem_title":"피보나치 수","solved_date":"20200203"},{"problem_number":"11656","problem_title":"접미사 배열","solved_date":"20200203"},{"problem_number":"10824","problem_title":"네 수","solved_date":"20200203"},{"problem_number":"2743","problem_title":"단어 길이 재기","solved_date":"20200203"},{"problem_number":"10820","problem_title":"문자열 분석","solved_date":"20200203"},{"problem_number":"10808","problem_title":"알파벳 개수","solved_date":"20200203"},{"problem_number":"11655","problem_title":"ROT13","solved_date":"20200203"},{"problem_number":"11720","problem_title":"숫자의 합","solved_date":"20200131"},{"problem_number":"1008","problem_title":"A/B","solved_date":"20200131"},{"problem_number":"10951","problem_title":"A+B - 4","solved_date":"20200131"},{"problem_number":"2557","problem_title":"Hello World","solved_date":"20200131"},{"problem_number":"1021","problem_title":"회전하는 큐","solved_date":"20200131"},{"problem_number":"1966","problem_title":"프린터 큐","solved_date":"20200131"},{"problem_number":"2164","problem_title":"카드2","solved_date":"20200131"},{"problem_number":"10799","problem_title":"쇠막대기","solved_date":"20200131"},{"problem_number":"17413","problem_title":"단어 뒤집기 2","solved_date":"20200131"},{"problem_number":"10866","problem_title":"덱","solved_date":"20200131"},{"problem_number":"1158","problem_title":"요세푸스 문제","solved_date":"20200131"},{"problem_number":"10845","problem_title":"큐","solved_date":"20200130"},{"problem_number":"1406","problem_title":"에디터","solved_date":"20200130"},{"problem_number":"1874","problem_title":"스택 수열","solved_date":"20200130"},{"problem_number":"9012","problem_title":"괄호","solved_date":"20200130"},{"problem_number":"9093","problem_title":"단어 뒤집기","solved_date":"20200130"},{"problem_number":"10828","problem_title":"스택","solved_date":"20200129"},{"problem_number":"11721","problem_title":"열 개씩 끊어 출력하기","solved_date":"20200126"},{"problem_number":"11719","problem_title":"그대로 출력하기 2","solved_date":"20200126"},{"problem_number":"11718","problem_title":"그대로 출력하기","solved_date":"20200126"},{"problem_number":"10953","problem_title":"A+B - 6","solved_date":"20200126"},{"problem_number":"2558","problem_title":"A+B - 2","solved_date":"20200126"},{"problem_number":"10814","problem_title":"나이순 정렬","solved_date":"20200123"},{"problem_number":"1181","problem_title":"단어 정렬","solved_date":"20200122"},{"problem_number":"11651","problem_title":"좌표 정렬하기 2","solved_date":"20200122"},{"problem_number":"11650","problem_title":"좌표 정렬하기","solved_date":"20200122"},{"problem_number":"1427","problem_title":"소트인사이드","solved_date":"20190823"},{"problem_number":"2108","problem_title":"통계학","solved_date":"20190823"},{"problem_number":"10989","problem_title":"수 정렬하기 3","solved_date":"20190823"},{"problem_number":"2751","problem_title":"수 정렬하기 2","solved_date":"20190814"},{"problem_number":"2750","problem_title":"수 정렬하기","solved_date":"20190814"},{"problem_number":"1436","problem_title":"영화감독 숌","solved_date":"20190814"},{"problem_number":"1018","problem_title":"체스판 다시 칠하기","solved_date":"20190814"},{"problem_number":"7568","problem_title":"덩치","solved_date":"20190814"},{"problem_number":"2231","problem_title":"분해합","solved_date":"20190814"},{"problem_number":"2798","problem_title":"블랙잭","solved_date":"20190814"},{"problem_number":"1002","problem_title":"터렛","solved_date":"20190814"},{"problem_number":"3053","problem_title":"택시 기하학","solved_date":"20190814"},{"problem_number":"4153","problem_title":"직각삼각형","solved_date":"20190814"},{"problem_number":"3009","problem_title":"네 번째 점","solved_date":"20190814"},{"problem_number":"1085","problem_title":"직사각형에서 탈출","solved_date":"20190814"},{"problem_number":"9020","problem_title":"골드바흐의 추측","solved_date":"20190814"},{"problem_number":"4948","problem_title":"베르트랑 공준","solved_date":"20190814"},{"problem_number":"1929","problem_title":"소수 구하기","solved_date":"20190814"},{"problem_number":"2581","problem_title":"소수","solved_date":"20190811"},{"problem_number":"1978","problem_title":"소수 찾기","solved_date":"20190811"},{"problem_number":"2292","problem_title":"벌집","solved_date":"20190811"},{"problem_number":"6064","problem_title":"카잉 달력","solved_date":"20190811"},{"problem_number":"2775","problem_title":"부녀회장이 될테야","solved_date":"20190811"},{"problem_number":"10250","problem_title":"ACM 호텔","solved_date":"20190811"},{"problem_number":"2869","problem_title":"달팽이는 올라가고 싶다","solved_date":"20190811"},{"problem_number":"1011","problem_title":"Fly me to the Alpha Centauri","solved_date":"20190811"},{"problem_number":"1193","problem_title":"분수찾기","solved_date":"20190810"},{"problem_number":"2839","problem_title":"설탕 배달","solved_date":"20190809"},{"problem_number":"1712","problem_title":"손익분기점","solved_date":"20190809"},{"problem_number":"1316","problem_title":"그룹 단어 체커","solved_date":"20190809"},{"problem_number":"2941","problem_title":"크로아티아 알파벳","solved_date":"20190809"},{"problem_number":"5622","problem_title":"다이얼","solved_date":"20190809"},{"problem_number":"2908","problem_title":"상수","solved_date":"20190809"},{"problem_number":"1152","problem_title":"단어의 개수","solved_date":"20190809"},{"problem_number":"1157","problem_title":"단어 공부","solved_date":"20190809"},{"problem_number":"2675","problem_title":"문자열 반복","solved_date":"20190809"},{"problem_number":"10809","problem_title":"알파벳 찾기","solved_date":"20190809"},{"problem_number":"11720","problem_title":"숫자의 합","solved_date":"20190809"},{"problem_number":"11654","problem_title":"아스키 코드","solved_date":"20190809"},{"problem_number":"11729","problem_title":"하노이 탑 이동 순서","solved_date":"20190809"},{"problem_number":"2447","problem_title":"별 찍기 - 10","solved_date":"20190809"},{"problem_number":"3052","problem_title":"나머지","solved_date":"20190807"},{"problem_number":"10818","problem_title":"최소, 최대","solved_date":"20190807"},{"problem_number":"10872","problem_title":"팩토리얼","solved_date":"20190628"},{"problem_number":"10870","problem_title":"피보나치 수 5","solved_date":"20190628"},{"problem_number":"1065","problem_title":"한수","solved_date":"20190628"},{"problem_number":"4673","problem_title":"셀프 넘버","solved_date":"20190628"},{"problem_number":"15596","problem_title":"정수 N개의 합","solved_date":"20190628"},{"problem_number":"4344","problem_title":"평균은 넘겠지","solved_date":"20190628"},{"problem_number":"2920","problem_title":"음계","solved_date":"20190628"},{"problem_number":"8958","problem_title":"OX퀴즈","solved_date":"20190628"},{"problem_number":"1546","problem_title":"평균","solved_date":"20190628"},{"problem_number":"2577","problem_title":"숫자의 개수","solved_date":"20190628"},{"problem_number":"2562","problem_title":"최댓값","solved_date":"20190628"},{"problem_number":"1110","problem_title":"더하기 사이클","solved_date":"20190628"},{"problem_number":"10951","problem_title":"A+B - 4","solved_date":"20190628"},{"problem_number":"10952","problem_title":"A+B - 5","solved_date":"20190628"},{"problem_number":"10871","problem_title":"X보다 작은 수","solved_date":"20190628"},{"problem_number":"2439","problem_title":"별 찍기 - 2","solved_date":"20190628"},{"problem_number":"2438","problem_title":"별 찍기 - 1","solved_date":"20190628"},{"problem_number":"11022","problem_title":"A+B - 8","solved_date":"20190628"},{"problem_number":"11021","problem_title":"A+B - 7","solved_date":"20190628"},{"problem_number":"2742","problem_title":"기찍 N","solved_date":"20190628"},{"problem_number":"2741","problem_title":"N 찍기","solved_date":"20190628"},{"problem_number":"15552","problem_title":"빠른 A+B","solved_date":"20190628"},{"problem_number":"8393","problem_title":"합","solved_date":"20190628"},{"problem_number":"10950","problem_title":"A+B - 3","solved_date":"20190628"},{"problem_number":"2739","problem_title":"구구단","solved_date":"20190628"},{"problem_number":"10817","problem_title":"세 수","solved_date":"20190627"},{"problem_number":"2884","problem_title":"알람 시계","solved_date":"20190627"},{"problem_number":"2753","problem_title":"윤년","solved_date":"20190627"},{"problem_number":"9498","problem_title":"시험 성적","solved_date":"20190627"},{"problem_number":"1330","problem_title":"두 수 비교하기","solved_date":"20190627"},{"problem_number":"2588","problem_title":"곱셈","solved_date":"20190627"},{"problem_number":"10430","problem_title":"나머지","solved_date":"20190627"},{"problem_number":"10869","problem_title":"사칙연산","solved_date":"20190627"},{"problem_number":"1008","problem_title":"A/B","solved_date":"20190627"},{"problem_number":"10998","problem_title":"A×B","solved_date":"20190627"},{"problem_number":"7287","problem_title":"등록","solved_date":"20190627"},{"problem_number":"10172","problem_title":"개","solved_date":"20190627"},{"problem_number":"10171","problem_title":"고양이","solved_date":"20190627"},{"problem_number":"10718","problem_title":"We love kriii","solved_date":"20190627"},{"problem_number":"1001","problem_title":"A-B","solved_date":"20190607"},{"problem_number":"1000","problem_title":"A+B","solved_date":"20190607"},{"problem_number":"2557","problem_title":"Hello World","solved_date":"20190607"}]
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.