Skip to content

Commit

Permalink
Merge pull request #13 from KNU-HAEDAL/issue/#7
Browse files Browse the repository at this point in the history
Issue/#7
  • Loading branch information
bayy1216 authored May 31, 2024
2 parents 3de7285 + 467acec commit 7d7602a
Show file tree
Hide file tree
Showing 13 changed files with 495 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ out/

### VS Code ###
.vscode/

/mysql-data
14 changes: 14 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'
# 실행명령어
# docker-compose -f ./docker-compose.dev.yml up
services:
zzansuni-mysql:
image: mysql
restart: always
volumes:
- ./mysql-data:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: zzansuni
MYSQL_ROOT_PASSWORD: root
13 changes: 13 additions & 0 deletions utils/node/make.challenge.group.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// INSERT INTO challenge_group (cumulative_count, created_at, last_modified_at, content, title, category)
// VALUES (100, '2023-05-31 10:00:00', '2023-05-31 12:00:00', 'This is a sample content', 'Sample Title', 'HEALTH');
import { fakerKO as faker } from "@faker-js/faker";

for(let i=0; i<20; i++) {
const category = ['HEALTH', 'ECHO', 'SHARE', 'VOLUNTEER'];
const selectedCategory = category[Math.floor(Math.random() * category.length)];
const content = faker.lorem.text().substring(0,254);
const title = faker.lorem.words(3);

const sql = `(100, '2023-05-31 10:00:00', '2023-05-31 12:00:00', '${content}', '${title}', '${selectedCategory}'),`;
console.log(sql);
}
16 changes: 16 additions & 0 deletions utils/node/make.challenge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { fakerKO as faker } from "@faker-js/faker";

for (let i = 0; i < 50; i++) {
const difficulty = faker.number.int({ min: 1, max: 5 });
const onceExp = faker.number.int({ min: 1, max: 30 });
const requiredCount = faker.number.int({ min: 5, max: 50 });
const successExp = faker.number.int({ min: 10, max: 100 });
const challengeGroupId = faker.number.int({ min: 1, max: 20 });
const createdAt = faker.date.past().toISOString().slice(0, 19).replace('T', ' ');
const lastModifiedAt = faker.date.recent().toISOString().slice(0, 19).replace('T', ' ');
const dayTypes = ['DAY', 'MONTH', 'WEEK'];
const dayType = dayTypes[Math.floor(Math.random() * dayTypes.length)];

const sql = `(${difficulty}, ${onceExp}, ${requiredCount}, ${successExp}, ${challengeGroupId}, '${createdAt}', '${lastModifiedAt}', '${dayType}'),`;
console.log(sql);
}
12 changes: 12 additions & 0 deletions utils/node/make.challenge.review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { fakerKO as faker } from "@faker-js/faker";

for (let i = 0; i < 50; i++) {
const rating = faker.number.int({ min: 1, max: 5 });
const createdAt = faker.date.past().toISOString().slice(0, 19).replace('T', ' ');
const lastModifiedAt = faker.date.recent().toISOString().slice(0, 19).replace('T', ' ');
const userChallengeId = faker.number.int({ min: 1, max: 50 });
const content = faker.lorem.sentence();

const sql = `(${rating}, '${createdAt}', '${lastModifiedAt}', ${userChallengeId}, '${content}'),`;
console.log(sql);
}
13 changes: 13 additions & 0 deletions utils/node/make.user.challenge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { fakerKO as faker } from "@faker-js/faker";

for (let i = 0; i < 50; i++) {
const challengeId = faker.number.int({ min: 1, max: 40 });
const userId = faker.number.int({ min: 1, max: 20 });
const createdAt = faker.date.past().toISOString().slice(0, 19).replace('T', ' ');
const lastModifiedAt = faker.date.recent().toISOString().slice(0, 19).replace('T', ' ');
const statuses = ['FINISHED', 'PROCEEDING'];
const status = statuses[Math.floor(Math.random() * statuses.length)];

const sql = `(${challengeId}, '${createdAt}', '${lastModifiedAt}', ${userId}, '${status}'),`;
console.log(sql);
}
8 changes: 8 additions & 0 deletions utils/node/make.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { fakerKO as faker } from "@faker-js/faker";
for(let i = 0; i < 20; i++) {
const name = faker.person.firstName();
const imageUrl = faker.image.url();
const randomExp = Math.floor(Math.random() * 100);
const sql = `(${randomExp}, '2023-05-31 10:00:00', '2023-05-31 12:00:00', null, 'test${i}@a.c', '${name}', '$2a$10$h1VlKrjjHSnuRoeCnl1reOh.oaAw6EqxrSMB0FVClpOb1S2D.K.ZK', '${imageUrl}', null, 'USER'),`;
console.log(sql);
}
14 changes: 14 additions & 0 deletions utils/node/make.verification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { fakerKO as faker } from "@faker-js/faker";

for (let i = 0; i < 50; i++) {
const createdAt = faker.date.past().toISOString().slice(0, 19).replace('T', ' ');
const lastModifiedAt = faker.date.recent().toISOString().slice(0, 19).replace('T', ' ');
const userChallengeId = faker.number.int({ min: 1, max: 50 });
const content = faker.lorem.sentence();
const imageUrl = faker.image.url();
const statuses = ['APPROVED', 'REJECTED', 'WAITING'];
const status = statuses[Math.floor(Math.random() * statuses.length)];

const sql = `('${createdAt}', '${lastModifiedAt}', ${userChallengeId}, '${content}', '${imageUrl}', '${status}'),`;
console.log(sql);
}
6 changes: 5 additions & 1 deletion utils/node/package-lock.json

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

2 changes: 1 addition & 1 deletion utils/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "api-insert-utils",
"version": "1.0.0",
"main": "main.js",
"devDependencies": {},
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.persistence.*;
import lombok.*;
import org.haedal.zzansuni.domain.BaseTimeEntity;
import org.haedal.zzansuni.domain.auth.OAuth2Provider;
import org.haedal.zzansuni.global.security.Role;

Expand All @@ -11,7 +12,7 @@
@Builder
@AllArgsConstructor
@Table(name = "users")
public class User {
public class User extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
2 changes: 1 addition & 1 deletion zzansuni-api-server/app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spring: # dev profile
password: "root"
jpa:
hibernate:
ddl-auto: update
ddl-auto: create
defer-datasource-initialization: true
sql.init.mode: always
---
Expand Down
Loading

0 comments on commit 7d7602a

Please sign in to comment.