Skip to content

Commit

Permalink
Merge pull request #39 from shortintern2020-A-labyrinth/masahito
Browse files Browse the repository at this point in the history
Masahito
  • Loading branch information
Highmt authored Aug 26, 2020
2 parents 74f0e21 + 3253a92 commit 5b031d5
Show file tree
Hide file tree
Showing 44 changed files with 900 additions and 121 deletions.
22 changes: 11 additions & 11 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
Expand Down
113 changes: 113 additions & 0 deletions .factorypath

Large diffs are not rendered by default.

Binary file added .gradle/6.5/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/6.5/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/6.5/fileHashes/fileHashes.lock
Binary file not shown.
Empty file added .gradle/6.5/gc.properties
Empty file.
Binary file added .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Wed Aug 26 19:54:40 JST 2020
gradle.version=6.5
Binary file added .gradle/checksums/checksums.lock
Binary file not shown.
Empty file added .gradle/vcs-1/gc.properties
Empty file.
4 changes: 3 additions & 1 deletion .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target\\generated-sources\\annotations
org.eclipse.jdt.apt.genTestSrcDir=target\\generated-test-sources\\test-annotations
2 changes: 1 addition & 1 deletion .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
File renamed without changes.
23 changes: 23 additions & 0 deletions docker/pg/1-createTable.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*テーブル作成*/
create table users (
id serial primary key,
name varchar(30) not null,
Expand Down Expand Up @@ -48,6 +49,7 @@ create table emojicode (
emoji_code varchar(30)
);


insert into users(name, mail, filterlevel) values
('ichigo.chocomint', '[email protected]', 1),
('banana.chocomint', '[email protected]', 2),
Expand Down Expand Up @@ -88,12 +90,33 @@ insert into requestfriend(userid, requestfriendid, create_at) values
(45, 67, '2019-07-19 07:19:19'),
(89, 12, '2020-08-20 08:20:20')
;

insert into users(name, mail, filterlevel) values
('ichigo.chocomint', '[email protected]', 1),
('banana.chocomint', '[email protected]', 2),
('pinapple.chocomint', '[email protected]', 3)
;

insert into emojicode(keyword, emoji_code) values
('radio', ':radio:'),
('movies', ':movie_camera:'),
('bowling',':bowling:'),
('bank',':bank:')
;

insert into talk(userid, friendid,contents,create_at) values
(100, 101,'Hello World !', current_timestamp),
(101,100, 'Hi !', current_timestamp),
(101,100,'See you.','2020-08-25 10:23:23')
;

insert into emolog(userid,friendid,create_at,contents) values
(101,100,'2020-08-25 10:23:23',':grinning: :smiley: :wink: :radio: :credit_card:'),
(100,101,'2020-08-25 10:23:23',':wink: :radio: :credit_card: :grinning: :smiley:')
;*/



insert into friend(userid, friendid, name, latestemolog) values
(1, 2, 'hoge', 'emojihoge'),
(2, 1, 'Trump', ':smile:'),
Expand Down
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@
</exclusion>
</exclusions>
</dependency>
<!-- emoji - java を使う -->
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>4.0.0</version>
</dependency>
<!--web socket を使う
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.3</version>
</dependency>-->
<dependency>
<groupId>org.seasar.doma.boot</groupId>
<artifactId>doma-spring-boot-starter</artifactId>
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/com/example/demo/DemoApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;


//public class DemoApplication implements CommandLineRunner {
@SpringBootApplication
public class DemoApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

// @Autowired
// JdbcTemplate jdbcTemplate;

@Override // アプリ起動時に実行される。
public void run(String... strings) throws Exception {
// jdbcTemplate.execute("CREATE TABLE customers(" +
// "id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))");
//
// jdbcTemplate.update("INSERT INTO customers(first_name, last_name) VALUES ('John','Woo')");
/*
jdbcTemplate.execute("CREATE TABLE customers(" +
"id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))");
jdbcTemplate.update("INSERT INTO customers(first_name, last_name) VALUES ('John','Woo')");
*/
}

}
142 changes: 142 additions & 0 deletions src/main/java/com/example/demo/controller/ChatController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package com.example.demo.controller;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ui.Model;

import java.util.List;
import java.util.Map;

//import java.util.Date;
import com.vdurmont.emoji.EmojiParser;

import org.springframework.stereotype.Controller;

//chatページの表示
@Controller
@RequestMapping(path = "/")
public class ChatController {

@Autowired
JdbcTemplate jdbcTemplate;

@RequestMapping(path = "/chat", method = RequestMethod.GET)
public String chat(Model model){
//日付
//Date date = new Date();

String date = "8月18日";
model.addAttribute("date", date);

//絵文字
//データを受け取る
int u_id = 1;
int f_id = 2;
//SELECT contents FROM emolog WHERE userid== AND friendid AND create_at==date;
/*List<Map<String, Object>> emojilist;
emojilist = jdbcTemplate.queryForList("SELECT * FROM emolog");
String MyEmolog ="";
String FriendEmolog ="";
for(Map<String, Object> map : emojilist) {
if(u_id == (Integer)map.get("userid") && f_id == (Integer)map.get("friendid") ){
//本当は一日分なので日付も欲しいですが
MyEmolog += map.get("contents");
}else if(f_id == (Integer)map.get("userid") && u_id == (Integer)map.get("friendid")){
FriendEmolog +=map.get("contents");
}
}*/

//絵文字の表示部分
//相手側
//String text = "An 😀awesome 😃string with a few 😉emojis!";
String text = ":grinning: :smiley: :wink: :radio: :credit_card: ";
//String text =FriendEmolog;
text = EmojiParser.parseToUnicode(text);
model.addAttribute("FriendEmolog", text);
//自分側
//text=MyEmolog;
text = EmojiParser.parseToUnicode(text);
model.addAttribute("MyEmolog", text);


//チャット部分の表示
/*List<Map<String, Object>> list;
//list = jdbcTemplate.queryForList("select * from users");
list = jdbcTemplate.queryForList("SELECT * FROM talk");
String MyMessage ="";
String FriendMessage ="";
for(Map<String, Object> map : list) {
if(u_id == (Integer)map.get("userid") && f_id == (Integer)map.get("friendid") ){
//本当は一日分なので日付も欲しいですが
MyMessage += map.get("contents");
}else if(f_id == (Integer)map.get("userid") && u_id == (Integer)map.get("friendid")){
FriendMessage +=map.get("contents");
}
}
model.addAttribute("MyChatMessage", MyMessage);
model.addAttribute("FriendChatMessage", FriendMessage);*/

return "chat";
}

/*自分用
@RequestMapping(path = "/", method = RequestMethod.GET)
public String twitter_connect(Model model){
model.addAttribute("MyEmolog", "Hello Springboot");
return "chat";
}*/


//テキストボックス入力
/*@RequestMapping(value = "/chat", method = RequestMethod.GET)
public String TextBox(Model model){
// 空のフォームオブジェクトをModelに設定
model.addAttribute("MessageBox", new Message());
// 遷移先を返す(この場合はinput.htmlが遷移先となる)
return "chat";
}*/

/*@RequestMapping(value = "/chat", method = RequestMethod.POST)
public String confirm(@ModelAttribute("MessageBox") Message form,Model model) {
// 空のフォームオブジェクトをModelに設定
model.addAttribute("MessageBox", new Message());
// 遷移先を返す(この場合はconfirm.htmlが遷移先となる)
return "chat";
}*/


//private static final Logger LOG = LoggerFactory.getLogger(ViewController.class);
/*
@Autowired
JdbcTemplate jdbcTemplate;
@RequestMapping(path = "/users", method = RequestMethod.GET)
public String index() {
List<Map<String, Object>> list;
list = jdbcTemplate.queryForList("select * from users");
return list.toString();
}
@RequestMapping(path = "/users/{id}", method = RequestMethod.GET)
public String read(@PathVariable("id") String id) {
List<Map<String, Object>> list;
list = jdbcTemplate.queryForList("select * from users where id = ?", id);
return list.toString();
}
@RequestMapping(path = "/", method = RequestMethod.GET)
public String twitter_connect() throws Exception{
return "";
}*/

}
10 changes: 8 additions & 2 deletions src/main/java/com/example/demo/controller/EmologController.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@


@Controller
@RequestMapping(path = "/emologlist")
@RequestMapping(path = "/")
public class EmologController {

@Autowired
/*@Autowired
EmologService service;
@RequestMapping(value="/{userid}/{friendid}",method=RequestMethod.GET)
Expand All @@ -30,6 +30,12 @@ public String selectAll(@PathVariable("userid") String userid, @PathVariable("fr
List<Emolog> emologs = service.selectAll(userId, friendId);
model.addAttribute("emologs", emologs);
return "emologlist";
}*/

@RequestMapping(path = "/emologlist")
public String chat(Model model){
return "emologlist";
}


}
10 changes: 7 additions & 3 deletions src/main/java/com/example/demo/controller/FriendController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@


@Controller
@RequestMapping(path = "/friendlist")
@RequestMapping(path = "/")
public class FriendController {

@Autowired
/*@Autowired
FriendService service;
@RequestMapping(value="/{userid}",method=RequestMethod.GET)
Expand All @@ -26,6 +26,10 @@ public String selectAll(@PathVariable("userid") String userid, Model model) {
List<Friend> friends = service.selectAll(userId);
model.addAttribute("friends", friends);
return "friendlist.html";
}
}*/

@RequestMapping(path = "/friendlist")
public String chat(Model model) {
return "friendlist";
}
}
3 changes: 0 additions & 3 deletions src/main/java/com/example/demo/controller/ViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ public List<String> collect_image_keywords_from_tweets(

}




// コントローラは関数として呼び出すのはキツイっぽいのでとりま関数として取り出してる。。
//TODO: TwitterControllerやNLUControllerから共通部分を分離して別クラスとして保持。
private static QueryResult search_user(String username, long tweet_id) throws TwitterException {
Expand Down
Loading

0 comments on commit 5b031d5

Please sign in to comment.