diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3ae32116b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.dockerignore +Dockerfile +docker-compose.yml + +.git/ +.gitignore/ + +target/ + diff --git a/.gitignore b/.gitignore index 8e24992a0..7a0cb9db2 100755 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ target .eclipse-pmd .checkstyle node +.idea +.m2 +knowledge.iml diff --git a/.travis.yml b/.travis.yml index d03d18c3c..1e77d5617 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: java jdk: oraclejdk8 - -install: mvn install -DskipTests=true -script: mvn test site +install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dmaven.exec.skip=true -B -V +script: mvn clean test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..5f9bf8ba9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +FROM node:8.6-alpine + +# Default to UTF-8 file.encoding +ENV LANG C.UTF-8 + +# install git +RUN apk update && apk upgrade && \ + apk add --no-cache bash git openssh + +# install jdk +RUN { \ + echo '#!/bin/sh'; \ + echo 'set -e'; \ + echo; \ + echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \ + } > /usr/local/bin/docker-java-home \ + && chmod +x /usr/local/bin/docker-java-home +ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk +ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin + +ENV JAVA_VERSION 8u131 +ENV JAVA_ALPINE_VERSION 8.131.11-r2 + +RUN set -x \ + && apk add --no-cache \ + openjdk8="$JAVA_ALPINE_VERSION" \ + && [ "$JAVA_HOME" = "$(docker-java-home)" ] + +# install maven +RUN apk add --no-cache curl tar bash + +ARG MAVEN_VERSION=3.5.0 +ARG USER_HOME_DIR="/root" +ARG SHA=beb91419245395bd69a4a6edad5ca3ec1a8b64e41457672dc687c173a495f034 +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ + && curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ + && echo "${SHA} /tmp/apache-maven.tar.gz" | sha256sum -c - \ + && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ + && rm -f /tmp/apache-maven.tar.gz \ + && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn + +ENV MAVEN_HOME /usr/share/maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +COPY mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh +COPY settings-docker.xml /usr/share/maven/ref/ + +VOLUME "$USER_HOME_DIR/.m2" + +ENTRYPOINT ["/usr/local/bin/mvn-entrypoint.sh"] +CMD ["mvn"] + +# RUN knowledge tool install +RUN npm install -g bower +RUN npm install -g gulp + +COPY package.json /usr/src/mymaven/ +COPY bower.json /usr/src/mymaven/ +COPY .bowerrc /usr/src/mymaven/ + +WORKDIR /usr/src/mymaven + +RUN npm install +RUN bower install --allow-root + + +#### RUN on docker-compose +# docker-compose build dev +# docker-compose run --rm dev mvn clean test diff --git a/README.md b/README.md index 19ea962db..3dfb099e3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,12 @@ ## About - Free Knowledge Management System +- [landing page and Online manual](https://information-knowledge.support-project.org/) +## Support +- **日本語での質問は、以下のサイトに登録してください(海外からのアクセスが多くなったため)** +- **For questions in Japanese, please register below** +- https://service-knowledge.support-project.org/ ## Live Demo - [https://test-knowledge.support-project.org](https://test-knowledge.support-project.org) @@ -23,13 +28,3 @@ ## How to initial set up - Please show the [wiki page](https://github.com/support-project/knowledge/wiki) - -## Project website (more info) -- [landing page and Online manual](https://information-knowledge.support-project.org/) - - - - - - - diff --git a/Third_party_license.txt b/Third_party_license.txt index de0235b13..d8fc9e003 100644 --- a/Third_party_license.txt +++ b/Third_party_license.txt @@ -202,5 +202,11 @@ - License: [BSD License] https://github.com/kpdecker/jsdiff/blob/master/LICENSE - project-url: https://github.com/kpdecker/jsdiff +- Chart.js + - License: [MIT License] https://github.com/chartjs/Chart.js/blob/master/LICENSE.md + - project-url: https://github.com/chartjs/Chart.js +- Vue.js + - License: [MIT License] https://github.com/vuejs/vue/blob/master/LICENSE + - project-url: https://jp.vuejs.org/index.html \ No newline at end of file diff --git a/bower.json b/bower.json index b223fe2b6..3e425746a 100644 --- a/bower.json +++ b/bower.json @@ -35,7 +35,9 @@ "bootstrap-table": "1.11.1", "tableExport.jquery.plugin": "1.8.1", "diff2html": "2.3.0", - "jsdiff": "3.2.0" + "jsdiff": "3.2.0", + "chart.js": "2.6.0", + "vue": "2.4.2" }, "devDependencies": {}, "resolutions": { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..23286514e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: '2.1' + +services: + dev: + image: knowledge-maven + build: + context: . + args: + - https_proxy + - http_proxy + links: + - mailcatcher + environment: + KNOWLEDGE_TEST_MAIL: 'false' + volumes: + - $PWD:/usr/src/mymaven + - $PWD/.m2:/root/.m2 + + mailcatcher: + image: "zolweb/docker-mailcatcher" + ports: + - "1025:1025" + - "1080:1080" + expose: + - "1080" diff --git a/document/database/A5M2_knowledge.pdf b/document/database/A5M2_knowledge.pdf index a6ef73af7..70de5485b 100755 Binary files a/document/database/A5M2_knowledge.pdf and b/document/database/A5M2_knowledge.pdf differ diff --git a/document/database/knowledge.a5er b/document/database/knowledge.a5er index 34604e0ca..603346399 100755 --- a/document/database/knowledge.a5er +++ b/document/database/knowledge.a5er @@ -46,14 +46,395 @@ SqlSeparator=0 ShowTag=1 ShowCommonAttributes=0 +[Entity] +PName=NOTIFICATION_STATUS +LName=いいねの通知状態 +Comment= +TableOption= +Page=MAIN +Left=2000 +Top=1450 +Field="種類","TYPE","@INT","NOT NULL",0,"","",$FFFFFFFF,"" +Field="ターゲットのID","TARGET_ID","bigint","NOT NULL",1,"","",$FFFFFFFF,"" +Field="登録者","USER_ID","@INT","NOT NULL",2,"","",$FFFFFFFF,"" +Field="通知の状態","STATUS","@INT",,,"","",$FFFFFFFF,"" +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20171002133707 +Position="MAIN",2000,1450 + +[Relation] +Entity1=MAIL_HOOK_CONDITIONS +Entity2=MAIL_HOOK_IGNORE_CONDITIONS +RelationType1=2 +RelationType2=3 +Fields1=HOOK_ID,CONDITION_NO +Fields2=HOOK_ID,CONDITION_NO +Cardinarity1= +Cardinarity2= +Position="MAIN",0,4923,4436,4098,R,R +Dependence=1 +Caption= +PName= +LineMode=0 +Bar1=492 +Bar2=444 +Bar3=410 +TermPos1=R +TermPos2=R + +[Entity] +PName=MAIL_HOOK_IGNORE_CONDITIONS +LName=メールから投稿の際の除外条件 +Comment= +TableOption= +Page=MAIN +Left=3400 +Top=2500 +Field="HOOK_ID","HOOK_ID","INTEGER","NOT NULL",0,"","",$FFFFFFFF,"" +Field="CONDITION_NO","CONDITION_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" +Field="IGNORE_CONDITION_NO","IGNORE_CONDITION_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,"" +Field="条件の種類","CONDITION_KIND","@INT","NOT NULL",,"","1:宛先が「条件文字」であった場合",$FFFFFFFF,"" +Field="条件の文字","CONDITION","@VARCHAR(256)",,,"","",$FFFFFFFF,"" +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170929133334 +Position="MAIN",3400,2500 + +[Comment] +Comment=TODO 初期値追加 +FontName=Tahoma +FontBold=0 +FontItalic=0 +FontUnderline=0 +FontSize=5 +FontColor=$000000 +LineColor=$000000 +BkColor=$FFFFFF +Page=Main +Left=1900 +Top=850 +Width=209 +Height=50 + +[Relation] +Entity1=ACTIVITIES +Entity2=POINT_USER_HISTORIES +RelationType1=1 +RelationType2=3 +Fields1=ACTIVITY_NO +Fields2=ACTIVITY_NO +Cardinarity1= +Cardinarity2= +Position="MAIN",0,5105,3901,4800,R,R +Dependence=0 +Caption= +PName= +LineMode=0 +Bar1=510 +Bar2=390 +Bar3=480 +TermPos1=R +TermPos2=R + +[Relation] +Entity1=USERS +Entity2=POINT_USER_HISTORIES +RelationType1=4 +RelationType2=3 +Fields1=USER_ID +Fields2=USER_ID +Cardinarity1= +Cardinarity2= +Position="MAIN",0,3607,6398,4351,R,R +Dependence=0 +Caption= +PName= +ModifiedDateTime=20170831112338 +LineMode=0 +Bar1=361 +Bar2=640 +Bar3=435 +TermPos1=R +TermPos2=R + +[Entity] +PName=POINT_USER_HISTORIES +LName=ユーザのポイント獲得履歴 +Comment= +TableOption= +Page=MAIN +Left=3500 +Top=850 +Field="ユーザID","USER_ID","INTEGER","NOT NULL",0,"","",$FFFFFFFF,"" +Field="履歴番号","HISTORY_NO","BIGINT","NOT NULL",1,"","",$FFFFFFFF,"" +Field="アクティビティ番号","ACTIVITY_NO","BIGINT","NOT NULL",,"","",$FFFFFFFF,"" +Field="獲得のタイプ","TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="獲得ポイント","POINT","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="獲得前ポイント","BEFORE_TOTAL","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="トータルポイント","TOTAL","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Index=IDX_POINT_USER_HISTORIES_INSERT_DATETIME=0,INSERT_DATETIME +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170907135513 +Position="MAIN",3500,850 + +[Relation] +Entity1=ACTIVITIES +Entity2=POINT_KNOWLEDGE_HISTORIES +RelationType1=4 +RelationType2=3 +Fields1=ACTIVITY_NO +Fields2=ACTIVITY_NO +Cardinarity1= +Cardinarity2= +Position="MAIN",0,6576,4612,6570,R,R +Dependence=0 +Caption= +PName= +ModifiedDateTime=20170831112218 +LineMode=0 +Bar1=658 +Bar2=461 +Bar3=657 +TermPos1=R +TermPos2=R + +[Relation] +Entity1=KNOWLEDGES +Entity2=POINT_KNOWLEDGE_HISTORIES +RelationType1=4 +RelationType2=3 +Fields1=KNOWLEDGE_ID +Fields2=KNOWLEDGE_ID +Cardinarity1= +Cardinarity2= +Position="MAIN",0,2911,5347,7802,R,R +Dependence=0 +Caption= +PName= +ModifiedDateTime=20170831112209 +LineMode=0 +Bar1=291 +Bar2=535 +Bar3=780 +TermPos1=R +TermPos2=R + +[Entity] +PName=POINT_KNOWLEDGE_HISTORIES +LName=ナレッジのポイント獲得履歴 +Comment= +TableOption= +Page=MAIN +Left=2450 +Top=1050 +Field="ナレッジID","KNOWLEDGE_ID","BIGINT","NOT NULL",0,"","",$FFFFFFFF,"" +Field="履歴番号","HISTORY_NO","BIGINT","NOT NULL",1,"","",$FFFFFFFF,"" +Field="アクティビティ番号","ACTIVITY_NO","BIGINT","NOT NULL",,"","",$FFFFFFFF,"" +Field="獲得のタイプ","TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="獲得ポイント","POINT","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="獲得前ポイント","BEFORE_TOTAL","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="トータルポイント","TOTAL","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Index=IDX_POINT_KNOWLEDGE_HISTORIES_INSERT_DATETIME=0,INSERT_DATETIME +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170907135426 +Position="MAIN",2450,1050 + +[Relation] +Entity1=BADGES +Entity2=USER_BADGES +RelationType1=2 +RelationType2=3 +Fields1=NO +Fields2=NO +Cardinarity1= +Cardinarity2= +Position="MAIN",0,4598,5968,5732,R,R +Dependence=1 +Caption= +PName= +ModifiedDateTime=20170829163644 +LineMode=0 +Bar1=460 +Bar2=597 +Bar3=573 +TermPos1=R +TermPos2=R + +[Relation] +Entity1=USERS +Entity2=USER_BADGES +RelationType1=1 +RelationType2=3 +Fields1=USER_ID +Fields2=USER_ID +Cardinarity1= +Cardinarity2= +Position="MAIN",0,4363,7074,3229,R,R +Dependence=1 +Caption= +PName= +LineMode=0 +Bar1=436 +Bar2=707 +Bar3=323 +TermPos1=R +TermPos2=R + +[Entity] +PName=USER_BADGES +LName=ユーザの称号 +Comment= +TableOption= +Page=MAIN +Left=2900 +Top=800 +Field="ユーザID","USER_ID","INTEGER","NOT NULL",0,"","",$FFFFFFFF,"" +Field="番号","NO","INTEGER","NOT NULL",1,"","",$FFFFFFFF,"" +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170829163555 +Position="MAIN",2900,800 + +[Relation] +Entity1=USERS +Entity2=ACTIVITIES +RelationType1=2 +RelationType2=3 +Fields1=USER_ID +Fields2=USER_ID +Cardinarity1= +Cardinarity2= +Position="MAIN",3,9500,5578,9500,R,R +Dependence=1 +Caption= +PName= +ModifiedDateTime=20170831112359 +LineMode=3 +Bar1=950 +Bar2=558 +Bar3=950 +TermPos1=R +TermPos2=R + +[Entity] +PName=ACTIVITIES +LName=アクティビティ +Comment= +TableOption= +Page=MAIN +Left=3450 +Top=1100 +Field="アクティビティ番号","ACTIVITY_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" +Field="イベントをおこしたユーザ","USER_ID","INTEGER","NOT NULL",,"","",$FFFFFFFF,"" +Field="アクティビティの種類","KIND","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="ターゲットID","TARGET","@VARCHAR(64)","NOT NULL",,"","",$FFFFFFFF,"" +Index=IDX_ACTIVITIES_USER_ID=0,USER_ID +Index=IDX_ACTIVITIES_KIND_TARGET=0,KIND,TARGET +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170831112153 +Position="MAIN",3450,1100 + +[Entity] +PName=USERS +LName=ユーザ +Comment= +TableOption= +Page=MAIN +Left=3500 +Top=500 +Field="ユーザID","USER_ID","SERIAL","NOT NULL",0,"","",$FFFFFFFF,"" +Field="ユーザKEY","USER_KEY","@VARCHAR(256)","NOT NULL",,"","ユニーク",$FFFFFFFF,"" +Field="ユーザ名","USER_NAME","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,"" +Field="パスワード","PASSWORD","@VARCHAR(1024)","NOT NULL",,"","ハッシュ(不可逆)",$FFFFFFFF,"" +Field="SALT","SALT","@VARCHAR(1024)",,,"","",$FFFFFFFF,"" +Field="ロケール","LOCALE_KEY","@VARCHAR(12)",,,"","",$FFFFFFFF,"" +Field="メールアドレス","MAIL_ADDRESS","@VARCHAR(256)",,,"","",$FFFFFFFF,"" +Field="LDAP認証ユーザかどうか","AUTH_LDAP","@INT",,,"","",$FFFFFFFF,"" +Index=IDX_USERS_USER_KEY=1,USER_KEY +NoDDL=1 +UsingCommonColumns=0 +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170829160846 +Position="MAIN",3500,500 + +[Entity] +PName=BADGES +LName=称号 +Comment= +TableOption= +Page=MAIN +Left=2900 +Top=450 +Field="番号","NO","SERIAL","NOT NULL",0,"","",$FFFFFFFF,"" +Field="名称","NAME","@VARCHAR(128)","NOT NULL",,"","",$FFFFFFFF,"" +Field="表示名","DISPLAY_TEXT","@VARCHAR(32)","NOT NULL",,"","",$FFFFFFFF,"" +Field="説明","DESCRIPTION","text",,,"","",$FFFFFFFF,"" +Field="画像","IMAGE","@VARCHAR(64)",,,"","",$FFFFFFFF,"" +Field="獲得ポイント","POINT","@INT",,,"","",$FFFFFFFF,"" +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170831113107 +Position="MAIN",2900,450 + +[Relation] +Entity1=COMMENTS +Entity2=LIKE_COMMENTS +RelationType1=1 +RelationType2=3 +Fields1=COMMENT_NO +Fields2=COMMENT_NO +Cardinarity1= +Cardinarity2= +Position="MAIN",0,3695,3149,4099,R,R +Dependence=0 +Caption= +PName= +LineMode=0 +Bar1=370 +Bar2=315 +Bar3=410 +TermPos1=R +TermPos2=R + +[Entity] +PName=LIKE_COMMENTS +LName=コメントのイイネ +Comment= +TableOption= +Page=MAIN +Left=1500 +Top=1450 +Field="NO","NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" +Field="コメント番号","COMMENT_NO","bigint","NOT NULL",,"","",$FFFFFFFF,"" +Field="種類","LIKE_CLASS","@INT",,,"1","",$FFFFFFFF,"" +Index=IDX_LIKE_COMMENTS_COMMENT_NO=0,COMMENT_NO +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170809123907 +Position="MAIN",1500,1450 + [Entity] PName=TOKENS LName=認証トークン Comment= TableOption= Page=MAIN -Left=1600 -Top=50 +Left=3600 +Top=300 Field="TOKEN","TOKEN","@VARCHAR(128)","NOT NULL",0,"","",$FFFFFFFF,"" Field="ユーザID","USER_ID","@INT","NOT NULL",,"","",$FFFFFFFF,"" Field="有効期限","EXPIRES","@DATETIME","NOT NULL",,"","",$FFFFFFFF,"" @@ -62,7 +443,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170620125822 -Position="MAIN",1600,50 +Position="MAIN",3600,300 [Relation] Entity1=MAIL_HOOKS @@ -73,14 +454,14 @@ Fields1=HOOK_ID Fields2=HOOK_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,1836,5081,4896,R,R +Position="MAIN",0,4930,5081,4887,R,R Dependence=1 Caption= PName= LineMode=0 -Bar1=184 +Bar1=493 Bar2=508 -Bar3=490 +Bar3=489 TermPos1=R TermPos2=R @@ -90,8 +471,8 @@ LName=メール受信設定 Comment= TableOption= Page=MAIN -Left=2950 -Top=50 +Left=3400 +Top=1600 Field="HOOK_ID","HOOK_ID","INTEGER","NOT NULL",0,"","",$FFFFFFFF,"" Field="PROPERTY_KEY","PROPERTY_KEY","@VARCHAR(128)","NOT NULL",1,"","",$FFFFFFFF,"" Field="PROPERTY_VALUE","PROPERTY_VALUE","@VARCHAR(256)",,,"","",$FFFFFFFF,"" @@ -99,7 +480,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170616214751 -Position="MAIN",2950,50 +Position="MAIN",3400,1600 [Relation] Entity1=LOCALES @@ -110,14 +491,14 @@ Fields1=KEY Fields2=KEY Cardinarity1= Cardinarity2= -Position="MAIN",0,5226,5024,4720,R,R +Position="MAIN",0,6268,5024,4481,R,R Dependence=1 Caption= PName= LineMode=0 -Bar1=523 +Bar1=627 Bar2=502 -Bar3=472 +Bar3=448 TermPos1=R TermPos2=R @@ -130,14 +511,14 @@ Fields1=TEMPLATE_ID Fields2=TEMPLATE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4464,5489,4842,R,R +Position="MAIN",0,4464,5489,3348,R,R Dependence=1 Caption= PName= LineMode=0 Bar1=446 Bar2=549 -Bar3=484 +Bar3=335 TermPos1=R TermPos2=R @@ -147,8 +528,8 @@ LName=ロケール毎のメールテンプレート Comment= TableOption= Page=MAIN -Left=3600 -Top=300 +Left=2950 +Top=100 Field="テンプレートID","TEMPLATE_ID","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" Field="キー","KEY","@VARCHAR(12)","NOT NULL",1,"","",$FFFFFFFF,"" Field=" タイトル","TITLE","text","NOT NULL",,"","",$FFFFFFFF,"" @@ -157,7 +538,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170228163618 -Position="MAIN",3600,300 +Position="MAIN",2950,100 [Entity] PName=LOCALES @@ -187,8 +568,8 @@ LName=メールテンプレート Comment= TableOption= Page=MAIN -Left=2950 -Top=200 +Left=2250 +Top=100 Field="テンプレートID","TEMPLATE_ID","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" Field="テンプレートタイトル","TEMPLATE_TITLE","@VARCHAR(128)","NOT NULL",,"","",$FFFFFFFF,"" Field="説明文","DESCRIPTION","text",,,"","",$FFFFFFFF,"" @@ -196,7 +577,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170301131519 -Position="MAIN",2950,200 +Position="MAIN",2250,100 [Relation] Entity1=SURVEY_ANSWERS @@ -207,15 +588,15 @@ Fields1=KNOWLEDGE_ID,ANSWER_ID Fields2=KNOWLEDGE_ID,ANSWER_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,5908,4092,2954,R,R +Position="MAIN",0,7787,4092,1607,R,R Dependence=1 Caption= PName= ModifiedDateTime=20170220204743 LineMode=0 -Bar1=591 +Bar1=779 Bar2=409 -Bar3=295 +Bar3=161 TermPos1=R TermPos2=R @@ -228,15 +609,15 @@ Fields1=KNOWLEDGE_ID Fields2=ITEM_NO Cardinarity1= Cardinarity2= -Position="MAIN",0,4194,5115,6185,R,R +Position="MAIN",0,4774,5115,5968,R,R Dependence=0 Caption= PName= ModifiedDateTime=20170220204434 LineMode=0 -Bar1=419 +Bar1=477 Bar2=512 -Bar3=618 +Bar3=597 TermPos1=R TermPos2=R @@ -246,8 +627,8 @@ LName=アンケートの回答の値 Comment= TableOption= Page=MAIN -Left=2450 -Top=1600 +Left=1800 +Top=2400 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="回答ID","ANSWER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="項目NO","ITEM_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,"" @@ -256,7 +637,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170222220138 -Position="MAIN",2450,1600 +Position="MAIN",1800,2400 [Relation] Entity1=SURVEYS @@ -267,14 +648,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4662,4335,5351,R,R +Position="MAIN",0,4662,4335,6993,R,R Dependence=0 Caption= PName= LineMode=0 Bar1=466 Bar2=434 -Bar3=535 +Bar3=699 TermPos1=R TermPos2=R @@ -284,15 +665,15 @@ LName=アンケートの回答 Comment= TableOption= Page=MAIN -Left=1950 -Top=1600 +Left=1550 +Top=2100 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="回答ID","ANSWER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170222215330 -Position="MAIN",1950,1600 +Position="MAIN",1550,2100 [Relation] Entity1=SURVEY_ITEMS @@ -303,7 +684,7 @@ Fields1=KNOWLEDGE_ID,ITEM_NO Fields2=KNOWLEDGE_ID,ITEM_NO Cardinarity1= Cardinarity2= -Position="MAIN",0,4139,4896,5177,R,R +Position="MAIN",0,4139,4896,3096,R,R Dependence=1 Caption= PName= @@ -311,7 +692,7 @@ ModifiedDateTime=20170220203851 LineMode=0 Bar1=414 Bar2=490 -Bar3=518 +Bar3=310 TermPos1=R TermPos2=R @@ -321,8 +702,8 @@ LName=アンケートの選択肢の値 Comment= TableOption= Page=MAIN -Left=2450 -Top=1100 +Left=1250 +Top=2650 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="項目NO","ITEM_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="選択肢番号","CHOICE_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,"" @@ -332,7 +713,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170220203842 -Position="MAIN",2450,1100 +Position="MAIN",1250,2650 [Relation] Entity1=SURVEYS @@ -343,15 +724,15 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4567,5433,6677,R,R +Position="MAIN",0,6505,5433,1090,R,R Dependence=1 Caption= PName= ModifiedDateTime=20170220203540 LineMode=0 -Bar1=457 +Bar1=650 Bar2=543 -Bar3=668 +Bar3=109 TermPos1=R TermPos2=R @@ -361,8 +742,8 @@ LName=アンケート項目 Comment= TableOption= Page=MAIN -Left=2500 -Top=1350 +Left=1200 +Top=2400 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="項目NO","ITEM_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="項目名","ITEM_NAME","@VARCHAR(32)","NOT NULL",,"","",$FFFFFFFF,"" @@ -372,7 +753,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170220203458 -Position="MAIN",2500,1350 +Position="MAIN",1200,2400 [Relation] Entity1=KNOWLEDGES @@ -383,14 +764,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,6731,2055,3130,R,R +Position="MAIN",0,6893,2055,3184,R,R Dependence=1 Caption= PName= LineMode=0 -Bar1=673 +Bar1=689 Bar2=206 -Bar3=313 +Bar3=318 TermPos1=R TermPos2=R @@ -400,8 +781,8 @@ LName=アンケート Comment= TableOption= Page=MAIN -Left=1950 -Top=1400 +Left=950 +Top=2100 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="タイトル","TITLE","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,"" Field="説明","DESCRIPTION","text",,,"","",$FFFFFFFF,"" @@ -409,7 +790,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170220203309 -Position="MAIN",1950,1400 +Position="MAIN",950,2100 [Relation] Entity1=EVENTS @@ -441,13 +822,13 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,8507,5008,6901,R,R +Position="MAIN",0,2626,3251,6901,R,R Dependence=1 Caption= PName= LineMode=0 -Bar1=851 -Bar2=501 +Bar1=263 +Bar2=325 Bar3=690 TermPos1=R TermPos2=R @@ -458,8 +839,8 @@ LName=イベント Comment= TableOption= Page=MAIN -Left=1350 -Top=1500 +Left=50 +Top=900 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="開催日","START_DATE_TIME","@DATETIME","NOT NULL",,"","UTC",$FFFFFFFF,"" Field="タイムゾーン","TIME_ZONE","@VARCHAR(64)",,,"","",$FFFFFFFF,"" @@ -468,7 +849,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170307155432 -Position="MAIN",1350,1500 +Position="MAIN",50,900 [Entity] PName=PARTICIPANTS @@ -476,8 +857,8 @@ LName=参加者 Comment= TableOption= Page=MAIN -Left=1350 -Top=1750 +Left=50 +Top=750 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="ユーザID","USER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="ステータス","STATUS","@INT","NOT NULL",,"","",$FFFFFFFF,"" @@ -485,7 +866,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170222215215 -Position="MAIN",1350,1750 +Position="MAIN",50,750 [Relation] Entity1=SERVICE_CONFIGS @@ -515,7 +896,7 @@ Comment= TableOption= Page=MAIN Left=1600 -Top=400 +Top=300 Field="サービス名","SERVICE_NAME","@VARCHAR(64)","NOT NULL",0,"","",$FFFFFFFF,"" Field="ロケールキー","LOCALE_KEY","@VARCHAR(12)","NOT NULL",1,"","",$FFFFFFFF,"" Field="トップページのHTML","PAGE_HTML","text",,,"","",$FFFFFFFF,"" @@ -523,7 +904,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170130131057 -Position="MAIN",1600,400 +Position="MAIN",1600,300 [Entity] PName=SERVICE_CONFIGS @@ -532,7 +913,7 @@ Comment= TableOption= Page=MAIN Left=1600 -Top=200 +Top=100 Field="サービス名","SERVICE_NAME","@VARCHAR(64)","NOT NULL",0,"","",$FFFFFFFF,"" Field="表示名","SERVICE_LABEL","@VARCHAR(24)","NOT NULL",,"","",$FFFFFFFF,"" Field="アイコン文字列","SERVICE_ICON","@VARCHAR(24)","NOT NULL",,"","",$FFFFFFFF,"" @@ -541,7 +922,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170131001923 -Position="MAIN",1600,200 +Position="MAIN",1600,100 [Entity] PName=PINS @@ -549,8 +930,8 @@ LName=ピン Comment= TableOption= Page=MAIN -Left=50 -Top=1900 +Left=700 +Top=2700 Field="NO","NO","serial","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="行ID","ROW_ID","@VARCHAR(64)",,,"","",$FFFFFFFF,"" @@ -559,7 +940,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20161206105257 -Position="MAIN",50,1900 +Position="MAIN",700,2700 [Relation] Entity1=WEBHOOK_CONFIGS @@ -570,7 +951,7 @@ Fields1=HOOK_ID Fields2=HOOK Cardinarity1= Cardinarity2= -Position="MAIN",0,4124,4194,3050,R,R +Position="MAIN",0,4124,4194,3971,R,R Dependence=0 Caption= PName= @@ -578,7 +959,7 @@ ModifiedDateTime=20161206104307 LineMode=0 Bar1=412 Bar2=419 -Bar3=305 +Bar3=397 TermPos1=R TermPos2=R @@ -589,7 +970,7 @@ Comment= TableOption= Page=MAIN Left=50 -Top=2250 +Top=2700 Field="WEBHOOK ID","WEBHOOK_ID","@VARCHAR(64)","NOT NULL",0,"","",$FFFFFFFF,"" Field="ステータス","STATUS","@INT","NOT NULL",,"","",$FFFFFFFF,"" Field="HOOK","HOOK","@VARCHAR(20)",,,"","",$FFFFFFFF,"" @@ -599,7 +980,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20161206105158 -Position="MAIN",50,2250 +Position="MAIN",50,2700 [Entity] PName=WEBHOOK_CONFIGS @@ -607,8 +988,8 @@ LName=Webhook 設定 Comment= TableOption= Page=MAIN -Left=50 -Top=2050 +Left=100 +Top=2500 Field="HOOK ID","HOOK_ID","serial","NOT NULL",0,"","",$FFFFFFFF,"" Field="HOOK","HOOK","@VARCHAR(20)","NOT NULL",,"","",$FFFFFFFF,"" Field="URL","URL","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,"" @@ -616,7 +997,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20161206103902 -Position="MAIN",50,2050 +Position="MAIN",100,2500 [Relation] Entity1=DRAFT_KNOWLEDGES @@ -686,7 +1067,7 @@ Comment= TableOption= Page=MAIN Left=1600 -Top=750 +Top=700 Field="下書きID","DRAFT_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="テンプレートの種類ID","TYPE_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="項目NO","ITEM_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,"" @@ -696,7 +1077,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20161118154223 -Position="MAIN",1600,750 +Position="MAIN",1600,700 [Entity] PName=DRAFT_KNOWLEDGES @@ -727,8 +1108,8 @@ LName=メールから投稿 Comment= TableOption= Page=MAIN -Left=2950 -Top=350 +Left=2250 +Top=300 Field="Message-ID","MESSAGE_ID","@VARCHAR(128)","NOT NULL",0,"","",$FFFFFFFF,"" Field="投稿区分","POST_KIND","@INT","NOT NULL",,"","1: Knowledge 2:Comment",$FFFFFFFF,"" Field="ID","ID","BIGINT","NOT NULL",,"","",$FFFFFFFF,"" @@ -737,7 +1118,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20160611082117 -Position="MAIN",2950,350 +Position="MAIN",2250,300 [Relation] Entity1=MAIL_HOOKS @@ -766,8 +1147,8 @@ LName=メールから投稿する条件 Comment= TableOption= Page=MAIN -Left=2300 -Top=350 +Left=3400 +Top=2050 Field="HOOK_ID","HOOK_ID","INTEGER","NOT NULL",0,"","",$FFFFFFFF,"" Field="CONDITION_NO","CONDITION_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="条件の種類","CONDITION_KIND","@INT","NOT NULL",,"","1:宛先が「条件文字」であった場合",$FFFFFFFF,"" @@ -784,7 +1165,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20160720194529 -Position="MAIN",2300,350 +Position="MAIN",3400,2050 [Entity] PName=MAIL_HOOKS @@ -792,8 +1173,8 @@ LName=受信したメールからの処理 Comment= TableOption= Page=MAIN -Left=2300 -Top=50 +Left=3400 +Top=1750 Field="HOOK_ID","HOOK_ID","SERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="MAIL_PROTOCOL","MAIL_PROTOCOL","@VARCHAR(10)","NOT NULL",,"","",$FFFFFFFF,"" Field="MAIL_HOST","MAIL_HOST","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,"" @@ -806,7 +1187,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20160603171116 -Position="MAIN",2300,50 +Position="MAIN",3400,1750 [Relation] Entity1=STOCKS @@ -817,7 +1198,7 @@ Fields1=STOCK_ID Fields2=STOCK_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4450,5090,4490,R,R +Position="MAIN",0,4450,5090,5933,R,R Dependence=1 Caption= PName= @@ -825,7 +1206,7 @@ ModifiedDateTime=20150910042933 LineMode=0 Bar1=445 Bar2=509 -Bar3=449 +Bar3=593 TermPos1=R TermPos2=R @@ -835,8 +1216,8 @@ LName=ストック Comment= TableOption= Page=MAIN -Left=50 -Top=1550 +Left=100 +Top=2250 Field="STOCK ID","STOCK_ID","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="STOCK 名","STOCK_NAME","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,"" Field="区分","STOCK_TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,"" @@ -845,7 +1226,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150910042830 -Position="MAIN",50,1550 +Position="MAIN",100,2250 [Relation] Entity1=TEMPLATE_ITEMS @@ -935,7 +1316,7 @@ Comment= TableOption= Page=MAIN Left=950 -Top=300 +Top=100 Field="テンプレートの種類ID","TYPE_ID","@INT","NOT NULL",0,"","",$FFFFFFFF,"" Field="項目NO","ITEM_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="選択肢番号","CHOICE_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,"" @@ -945,7 +1326,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150910041119 -Position="MAIN",950,300,542,135 +Position="MAIN",950,100,542,135 [Relation] Entity1=TEMPLATE_MASTERS @@ -956,7 +1337,7 @@ Fields1=TYPE_ID Fields2=TYPE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4460,6903,3568,R,R +Position="MAIN",0,4460,6903,3717,R,R Dependence=1 Caption= PName= @@ -964,7 +1345,7 @@ ModifiedDateTime=20150910034230 LineMode=0 Bar1=446 Bar2=690 -Bar3=357 +Bar3=372 TermPos1=R TermPos2=R @@ -977,14 +1358,14 @@ Fields1=TYPE_ID Fields2=TYPE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,3334,5475,2219,R,R +Position="MAIN",0,3334,5475,2295,R,R Dependence=0 Caption= PName= LineMode=0 Bar1=333 Bar2=548 -Bar3=222 +Bar3=230 TermPos1=R TermPos2=R @@ -1000,10 +1381,11 @@ Field="テンプレートの種類ID","TYPE_ID","serial","NOT NULL",0,"","",$FFF Field="テンプレート名","TYPE_NAME","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,"" Field="アイコン","TYPE_ICON","@VARCHAR(64)",,,"","",$FFFFFFFF,"" Field="説明","DESCRIPTION","@VARCHAR(1024)",,,"","",$FFFFFFFF,"" +Field="本文の初期値","INITIAL_VALUE","text",,,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150912014311 +ModifiedDateTime=20170915171119 Position="MAIN",650,550 [Entity] @@ -1013,17 +1395,18 @@ Comment= TableOption= Page=MAIN Left=1350 -Top=550 +Top=450 Field="テンプレートの種類ID","TYPE_ID","@INT","NOT NULL",0,"","",$FFFFFFFF,"" Field="項目NO","ITEM_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="項目名","ITEM_NAME","@VARCHAR(32)","NOT NULL",,"","",$FFFFFFFF,"" Field="項目の種類","ITEM_TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,"" Field="説明","DESCRIPTION","@VARCHAR(1024)",,,"","",$FFFFFFFF,"" +Field="初期値","INITIAL_VALUE","text",,,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20151027035632 -Position="MAIN",1350,550 +ModifiedDateTime=20170915171315 +Position="MAIN",1350,450 [Relation] Entity1=KNOWLEDGES @@ -1034,13 +1417,13 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",3,8366,5077,5634,R,R +Position="MAIN",3,1165,5077,5634,R,R Dependence=1 Caption= PName= ModifiedDateTime=20161206103019 LineMode=3 -Bar1=837 +Bar1=116 Bar2=508 Bar3=563 TermPos1=R @@ -1052,15 +1435,15 @@ LName=編集可能なグループ Comment= TableOption= Page=MAIN -Left=650 -Top=1900 +Left=150 +Top=1800 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="GROUP_ID","GROUP_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150517064451 -Position="MAIN",650,1900 +Position="MAIN",150,1800 [Relation] Entity1=KNOWLEDGES @@ -1071,13 +1454,13 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",3,7515,3356,9481,R,R +Position="MAIN",3,500,3356,9481,R,R Dependence=1 Caption= PName= ModifiedDateTime=20170307155611 LineMode=3 -Bar1=752 +Bar1=50 Bar2=336 Bar3=948 TermPos1=R @@ -1089,15 +1472,15 @@ LName=編集可能なユーザ Comment= TableOption= Page=MAIN -Left=650 -Top=1800 +Left=150 +Top=1700 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="USER_ID","USER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150517063424 -Position="MAIN",650,1800 +Position="MAIN",150,1700 [Relation] Entity1=KNOWLEDGES @@ -1108,7 +1491,7 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,5026,7091,5584,R,R +Position="MAIN",0,5026,7091,6103,R,R Dependence=1 Caption= PName= @@ -1116,7 +1499,7 @@ ModifiedDateTime=20150910041644 LineMode=0 Bar1=503 Bar2=709 -Bar3=558 +Bar3=610 TermPos1=R TermPos2=R @@ -1127,7 +1510,7 @@ Comment= TableOption= Page=MAIN Left=50 -Top=1100 +Top=1400 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="履歴番号","HISTORY_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" Field="タイトル","TITLE","@VARCHAR(1024)","NOT NULL",,"","",$FFFFFFFF,"" @@ -1141,7 +1524,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150507141708 -Position="MAIN",50,1100 +Position="MAIN",50,1400 [Entity] PName=NOTIFY_QUEUES @@ -1150,7 +1533,7 @@ Comment= TableOption= Page=MAIN Left=50 -Top=500 +Top=450 Field="HASH","HASH","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" Field="種類","TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,"" Field="通知する種類のID","ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" @@ -1158,7 +1541,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150331055404 -Position="MAIN",50,500 +Position="MAIN",50,450 [Entity] PName=NOTIFY_CONFIGS @@ -1167,7 +1550,7 @@ Comment= TableOption= Page=MAIN Left=50 -Top=140 +Top=100 Field="ユーザID","USER_ID","@INT","NOT NULL",0,"","",$FFFFFFFF,"" Field="メール通知する","NOTIFY_MAIL","@INT",,,"","",$FFFFFFFF,"" Field="デスクトップ通知する","NOTIFY_DESKTOP","@INT",,,"","",$FFFFFFFF,"" @@ -1183,7 +1566,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150328062820 -Position="MAIN",50,140 +Position="MAIN",50,100 [Relation] Entity1=COMMENTS @@ -1194,14 +1577,14 @@ Fields1=COMMENT_NO Fields2=COMMENT_NO Cardinarity1= Cardinarity2= -Position="MAIN",0,5486,4072,4707,R,R +Position="MAIN",0,5554,4072,2816,R,R Dependence=0 Caption= PName= LineMode=0 -Bar1=549 +Bar1=555 Bar2=407 -Bar3=471 +Bar3=282 TermPos1=R TermPos2=R @@ -1211,8 +1594,8 @@ LName=アカウントの画像 Comment= TableOption= Page=MAIN -Left=900 -Top=50 +Left=3500 +Top=1300 Field="IMAGE_ID","IMAGE_ID","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ユーザID","USER_ID","@INT",,,"","",$FFFFFFFF,"" Field="ファイル名","FILE_NAME","@VARCHAR(256)",,,"","",$FFFFFFFF,"" @@ -1225,7 +1608,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416234339 -Position="MAIN",900,50 +Position="MAIN",3500,1300 [Relation] Entity1=KNOWLEDGES @@ -1236,14 +1619,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,1535,6913,5217,R,R +Position="MAIN",0,6168,6867,1373,R,R Dependence=0 Caption= PName= LineMode=0 -Bar1=154 -Bar2=691 -Bar3=522 +Bar1=617 +Bar2=687 +Bar3=137 TermPos1=R TermPos2=R @@ -1253,16 +1636,17 @@ LName=いいね Comment= TableOption= Page=MAIN -Left=50 -Top=650 +Left=1500 +Top=1600 Field="NO","NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" +Field="種類","LIKE_CLASS","@INT",,,"1","",$FFFFFFFF,"" Index=IDX_LIKES_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150416233511 -Position="MAIN",50,650 +ModifiedDateTime=20170809123852 +Position="MAIN",1500,1600 [Relation] Entity1=KNOWLEDGES @@ -1291,7 +1675,7 @@ LName=コメント Comment= TableOption= Page=MAIN -Left=1600 +Left=1500 Top=1250 Field="コメント番号","COMMENT_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" @@ -1302,7 +1686,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150910035117 -Position="MAIN",1600,1250 +Position="MAIN",1500,1250 [Relation] Entity1=KNOWLEDGES @@ -1313,14 +1697,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",3,6828,5116,5997,R,R +Position="MAIN",2,500,6854,5997,R,R Dependence=0 Caption= PName= -ModifiedDateTime=20161118152345 -LineMode=3 -Bar1=683 -Bar2=512 +ModifiedDateTime=20171002125604 +LineMode=2 +Bar1=50 +Bar2=685 Bar3=600 TermPos1=R TermPos2=R @@ -1332,7 +1716,7 @@ Comment= TableOption= Page=MAIN Left=50 -Top=1700 +Top=600 Field="VOTE_NO","VOTE_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="投票区分","VOTE_KIND","@INT","NOT NULL",,"","",$FFFFFFFF,"" @@ -1341,7 +1725,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416233659 -Position="MAIN",50,1700,435,89 +Position="MAIN",50,600,435,89 [Relation] Entity1=KNOWLEDGES @@ -1352,14 +1736,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,7005,6407,5990,R,R +Position="MAIN",3,2678,6446,5990,R,R Dependence=1 Caption= PName= -ModifiedDateTime=20141204130740 -LineMode=0 -Bar1=700 -Bar2=641 +ModifiedDateTime=20171002130417 +LineMode=3 +Bar1=268 +Bar2=645 Bar3=599 TermPos1=R TermPos2=R @@ -1370,17 +1754,19 @@ LName=ナレッジの参照履歴 Comment= TableOption= Page=MAIN -Left=50 -Top=1400 +Left=100 +Top=2100 Field="HISTORY_NO","HISTORY_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="日時","VIEW_DATE_TIME","@DATETIME","NOT NULL",,"","",$FFFFFFFF,"" Index=IDX_VIEW_HISTORIES_KNOWLEDGE_ID=0,KNOWLEDGE_ID +Index=IDX_VIEW_HISTORIES_INSERT_USER=0,INSERT_USER +Index=IDX_VIEW_HISTORIES_KNOWLEDGE_ID_INSERT_USER=0,KNOWLEDGE_ID,INSERT_USER EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150416233623 -Position="MAIN",50,1400 +ModifiedDateTime=20170705135644 +Position="MAIN",100,2100 [Relation] Entity1=KNOWLEDGES @@ -1391,15 +1777,15 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,2082,5725,4629,R,R +Position="MAIN",0,3762,5725,4566,R,R Dependence=1 Caption= PName= ModifiedDateTime=20150910042925 LineMode=0 -Bar1=208 +Bar1=376 Bar2=572 -Bar3=463 +Bar3=457 TermPos1=R TermPos2=R @@ -1409,8 +1795,8 @@ LName=ストックしたナレッジ Comment= TableOption= Page=MAIN -Left=600 -Top=1550 +Left=700 +Top=2250 Field="STOCK ID","STOCK_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",1,"","",$FFFFFFFF,"" Field="コメント","COMMENT","@VARCHAR(1024)",,,"","",$FFFFFFFF,"" @@ -1418,7 +1804,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150910042912 -Position="MAIN",600,1550 +Position="MAIN",700,2250 [Relation] Entity1=KNOWLEDGES @@ -1429,13 +1815,13 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",3,9499,4332,5676,R,R +Position="MAIN",3,2265,4332,5676,R,R Dependence=1 Caption= PName= ModifiedDateTime=20161206103135 LineMode=3 -Bar1=950 +Bar1=226 Bar2=433 Bar3=568 TermPos1=R @@ -1447,15 +1833,15 @@ LName=アクセス可能なグループ Comment= TableOption= Page=MAIN -Left=650 -Top=2100 +Left=150 +Top=2000 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="GROUP_ID","GROUP_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20141222154841 -Position="MAIN",650,2100 +Position="MAIN",150,2000 [Relation] Entity1=KNOWLEDGES @@ -1466,13 +1852,13 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",3,8922,5233,1847,R,R +Position="MAIN",3,1715,5233,1847,R,R Dependence=1 Caption= PName= ModifiedDateTime=20170307155631 LineMode=3 -Bar1=892 +Bar1=172 Bar2=523 Bar3=185 TermPos1=R @@ -1484,15 +1870,15 @@ LName=アクセス可能なユーザ Comment= TableOption= Page=MAIN -Left=650 -Top=2000 +Left=150 +Top=1900 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="USER_ID","USER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150517063359 -Position="MAIN",650,2000 +Position="MAIN",150,1900 [Relation] Entity1=TAGS @@ -1503,14 +1889,14 @@ Fields1=TAG_ID Fields2=TAG_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4552,5672,4658,R,R +Position="MAIN",0,4552,5672,4653,R,R Dependence=1 Caption= PName= LineMode=0 Bar1=455 Bar2=567 -Bar3=466 +Bar3=465 TermPos1=R TermPos2=R @@ -1523,12 +1909,12 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,2923,5592,6381,R,R +Position="MAIN",0,4015,5592,6381,R,R Dependence=1 Caption= PName= LineMode=0 -Bar1=292 +Bar1=402 Bar2=559 Bar3=638 TermPos1=R @@ -1541,14 +1927,14 @@ Comment= TableOption= Page=MAIN Left=50 -Top=950 +Top=1250 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="タグ_ID","TAG_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20141222154737 -Position="MAIN",50,950 +Position="MAIN",50,1250,407,50 [Entity] PName=TAGS @@ -1557,14 +1943,14 @@ Comment= TableOption= Page=MAIN Left=50 -Top=750 +Top=1100 Field="タグ_ID","TAG_ID","SERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="タグ名称","TAG_NAME","@VARCHAR(128)","NOT NULL",,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416233544 -Position="MAIN",50,750 +Position="MAIN",50,1100 [Relation] Entity1=KNOWLEDGES @@ -1626,12 +2012,14 @@ Field="タグID一覧","TAG_IDS","@VARCHAR(1024)",,,"","",$FFFFFFFF,"" Field="タグ名称一覧","TAG_NAMES","text",,,"","",$FFFFFFFF,"" Field="いいね件数","LIKE_COUNT","bigint",,,"","",$FFFFFFFF,"" Field="コメント件数","COMMENT_COUNT","@INT",,,"","",$FFFFFFFF,"" +Field="参照件数","VIEW_COUNT","bigint",,,"","",$FFFFFFFF,"" Field="テンプレートの種類ID","TYPE_ID","@INT",,,"","",$FFFFFFFF,"" Field="通知ステータス","NOTIFY_STATUS","@INT",,,"","",$FFFFFFFF,"" +Field="ポイント","POINT","@INT","NOT NULL",,"0","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20161118153424 +ModifiedDateTime=20170829164715 Position="MAIN",700,1100 [Comment] diff --git a/gulpfile.js b/gulpfile.js index 28e36ec58..12a580126 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,6 +14,7 @@ gulp.task('min', function() { .pipe(replace('href="<%= request.getContextPath() %>/css', 'href="/css')) .pipe(replace('src="<%= request.getContextPath() %>/bower', 'src="/bower')) .pipe(replace('src="<%= request.getContextPath() %>/js', 'src="/js')) + .pipe(replace('<%= request.getContextPath() %>/EasyWizard', '/EasyWizard')) .pipe(usemin({ css: [rev], htmlmin: [ function () {return minifyHtml({ empty: true });} ], diff --git a/mvn-entrypoint.sh b/mvn-entrypoint.sh new file mode 100755 index 000000000..b80c27886 --- /dev/null +++ b/mvn-entrypoint.sh @@ -0,0 +1,39 @@ +#! /bin/bash -eu + +set -o pipefail + +# Copy files from /usr/share/maven/ref into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup +copy_reference_file() { + local root="${1}" + local f="${2%/}" + local logfile="${3}" + local rel="${f/${root}/}" # path relative to /usr/share/maven/ref/ + echo "$f" >> "$logfile" + echo " $f -> $rel" >> "$logfile" + if [[ ! -e ${MAVEN_CONFIG}/${rel} || $f = *.override ]] + then + echo "copy $rel to ${MAVEN_CONFIG}" >> "$logfile" + mkdir -p "${MAVEN_CONFIG}/$(dirname "${rel}")" + cp -r "${f}" "${MAVEN_CONFIG}/${rel}"; + fi; +} + +copy_reference_files() { + local log="$MAVEN_CONFIG/copy_reference_file.log" + + if (touch "${log}" > /dev/null 2>&1) + then + echo "--- Copying files at $(date)" >> "$log" + find /usr/share/maven/ref/ -type f -exec bash -eu -c 'copy_reference_file /usr/share/maven/ref/ "$1" "$2"' _ {} "$log" \; + else + echo "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + fi +} + +export -f copy_reference_file +copy_reference_files +unset MAVEN_CONFIG + +exec "$@" diff --git a/package.json b/package.json index 582d9e6cb..b62efa4e9 100644 --- a/package.json +++ b/package.json @@ -7,15 +7,14 @@ "url": "https://github.com/support-project/knowledge" }, "dependencies": { - "bower": "^1.8.0", - "gulp": "^3.9.1", - "gulp-usemin": "^0.3.26", - "gulp-uglify": "^0.3.1", - "gulp-minify-html": "^0.1.4", - "gulp-minify-css": "^0.3.7", - "gulp-rev": "^7.1.2", - "gulp-replace": "^0.5.4", - "npm": "^3.10.9" + "bower": "1.8.2", + "gulp": "3.9.1", + "gulp-usemin": "0.3.28", + "gulp-uglify": "0.3.2", + "gulp-minify-html": "0.1.8", + "gulp-minify-css": "0.3.13", + "gulp-rev": "7.1.2", + "gulp-replace": "0.5.4" }, "devDependencies": {}, "scripts": { diff --git a/pom.xml b/pom.xml index 0b38d7c14..871c61cd2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.support-project knowledge - 1.10.0 + 1.11.0 war knowledge @@ -59,7 +59,7 @@ org.support-project web - 1.10.0 + 1.11.1 @@ -194,38 +194,47 @@ - org.apache.maven.plugins - maven-war-plugin - 2.6 - - false - - - WEB-INF/views/**/*.jsp,bower/**/* - - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.3 + org.jacoco + jacoco-maven-plugin + 0.7.9 - package - copy + default-prepare-agent + + prepare-agent + + + + default-report + prepare-package + + report + + + + default-check + + check + - - - com.github.jsimone - webapp-runner - 8.0.33.4 - webapp-runner.jar - - + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.01 + + + + + + + + org.codehaus.mojo + exec-maven-plugin + + ${maven.exec.skip} + + + + npm + generate-resources + + npm + + install + + + + + bower + generate-resources + + bower + + install + + + + + gulp + prepare-package + + gulp + + default + + + + exec + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + false + + WEB-INF/views/**/*.jsp,bower/**/* + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.3 + + + package + copy + + + + com.github.jsimone + webapp-runner + 8.0.33.4 + webapp-runner.jar + + + + + + + @@ -321,6 +408,24 @@ + + org.jacoco + jacoco-maven-plugin + + + + report + + + + + + **/gen/** + **/deploy/** + + + + diff --git a/settings-docker.xml b/settings-docker.xml new file mode 100755 index 000000000..586c587c1 --- /dev/null +++ b/settings-docker.xml @@ -0,0 +1,6 @@ + + /usr/share/maven/ref/repository + diff --git a/src/main/java/org/support/project/knowledge/bat/AggregateBat.java b/src/main/java/org/support/project/knowledge/bat/AggregateBat.java new file mode 100644 index 000000000..b9070b654 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/bat/AggregateBat.java @@ -0,0 +1,36 @@ +package org.support.project.knowledge.bat; + +import org.apache.commons.lang.ClassUtils; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.logic.AggregateLogic; + +public class AggregateBat extends AbstractBat { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AggregateBat.class); + + public static void main(String[] args) throws Exception { + try { + initLogName("AggregateBat.log"); + configInit(ClassUtils.getShortClassName(AggregateBat.class)); + + AggregateBat bat = new AggregateBat(); + bat.dbInit(); + bat.start(); + + finishInfo(); + } catch (Exception e) { + LOG.error("any error", e); + throw e; + } + } + + /** + * 処理の実行 + * @throws Exception Exception + */ + public void start() throws Exception { + AggregateLogic aggregateLogic = AggregateLogic.get(); + aggregateLogic.startAggregate(); + } +} diff --git a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java index 3aa05dedb..d6f56a2a8 100644 --- a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java +++ b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java @@ -13,6 +13,7 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.knowledge.logic.MailLogic; +import org.support.project.web.dao.MailsDao; /** * メールの送信処理は、時間がかかるため、バッチ処理の中で処理する @@ -54,6 +55,8 @@ public static void main(String[] args) throws Exception { public void start() throws UnsupportedEncodingException, MessagingException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { MailLogic.get().startSendMails(); + int deletecount = MailsDao.get().physicalDeleteOnOldData(); + LOG.info("delete old mails. [count]" + deletecount); } } diff --git a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java index 81780c874..504617199 100644 --- a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java +++ b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java @@ -9,8 +9,11 @@ import org.support.project.knowledge.dao.NotifyQueuesDao; import org.support.project.knowledge.entity.NotifyQueuesEntity; import org.support.project.knowledge.logic.MailEventLogic; -import org.support.project.knowledge.logic.MailLogic; -import org.support.project.knowledge.vo.Notify; +import org.support.project.knowledge.logic.notification.CommentInsertNotification; +import org.support.project.knowledge.logic.notification.CommentLikedNotification; +import org.support.project.knowledge.logic.notification.KnowledgeUpdateNotification; +import org.support.project.knowledge.logic.notification.LikeInsertNotification; +import org.support.project.knowledge.logic.notification.QueueNotification; /** * メッセージ処理を処理する定期的なバッチプログラム @@ -50,13 +53,15 @@ private void start() throws Exception { NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); List notifyQueuesEntities = notifyQueuesDao.selectAll(); for (NotifyQueuesEntity notifyQueuesEntity : notifyQueuesEntities) { - if (notifyQueuesEntity.getType() == Notify.TYPE_KNOWLEDGE_INSERT - || notifyQueuesEntity.getType() == Notify.TYPE_KNOWLEDGE_UPDATE) { - MailLogic.get().notifyKnowledgeUpdate(notifyQueuesEntity); - } else if (notifyQueuesEntity.getType() == Notify.TYPE_KNOWLEDGE_COMMENT) { - MailLogic.get().notifyCommentInsert(notifyQueuesEntity); - } else if (notifyQueuesEntity.getType() == Notify.TYPE_KNOWLEDGE_LIKE) { - MailLogic.get().notifyLikeInsert(notifyQueuesEntity); + if (notifyQueuesEntity.getType() == QueueNotification.TYPE_KNOWLEDGE_INSERT + || notifyQueuesEntity.getType() == QueueNotification.TYPE_KNOWLEDGE_UPDATE) { + KnowledgeUpdateNotification.get().notify(notifyQueuesEntity); + } else if (notifyQueuesEntity.getType() == QueueNotification.TYPE_KNOWLEDGE_COMMENT) { + CommentInsertNotification.get().notify(notifyQueuesEntity); + } else if (notifyQueuesEntity.getType() == QueueNotification.TYPE_KNOWLEDGE_LIKE) { + LikeInsertNotification.get().notify(notifyQueuesEntity); + } else if (notifyQueuesEntity.getType() == QueueNotification.TYPE_COMMENT_LIKE) { + CommentLikedNotification.get().notify(notifyQueuesEntity); } // 通知のキューから削除 //notifyQueuesDao.delete(notifyQueuesEntity); diff --git a/src/main/java/org/support/project/knowledge/config/AppConfig.java b/src/main/java/org/support/project/knowledge/config/AppConfig.java index ed82a5101..3cb6fd6c7 100644 --- a/src/main/java/org/support/project/knowledge/config/AppConfig.java +++ b/src/main/java/org/support/project/knowledge/config/AppConfig.java @@ -22,6 +22,8 @@ public static AppConfig get() { private boolean convSlidePath = false; + private boolean maintenanceMode = false; + /** * @return the indexPath @@ -71,4 +73,18 @@ public void setSlidePath(String slidePath) { this.slidePath = slidePath; } + /** + * @return the maintenanceMode + */ + public boolean isMaintenanceMode() { + return maintenanceMode; + } + + /** + * @param maintenanceMode the maintenanceMode to set + */ + public void setMaintenanceMode(boolean maintenanceMode) { + this.maintenanceMode = maintenanceMode; + } + } diff --git a/src/main/java/org/support/project/knowledge/config/SystemConfig.java b/src/main/java/org/support/project/knowledge/config/SystemConfig.java index 27e880533..ba27710cc 100644 --- a/src/main/java/org/support/project/knowledge/config/SystemConfig.java +++ b/src/main/java/org/support/project/knowledge/config/SystemConfig.java @@ -17,6 +17,8 @@ public class SystemConfig { //public static final String KNOWLEDGE_ENV_KEY = "KNOWLEDGE_HOME"; + public static final int SYSTEM_USER_ID = -1; + /** システム設定情報 */ private static ServiceConfigsEntity serviceConfigsEntity = null; /** 言語毎のシステム設定情報 */ @@ -59,6 +61,13 @@ public class SystemConfig { /** 全ての機能は、ログインしないとアクセス出来ない */ public static final String SYSTEM_EXPOSE_TYPE_CLOSE = "CLOSE"; + /** いいね!の登録制限の設定キー */ + public static final String LIKE_CONFIG = "LIKE_CONFIG"; + /** いいね!の登録制限の値:複数回押せる */ + public static final String LIKE_CONFIG_MANY = "MANY"; + /** いいね!の登録制限の値:1回のみ押せる(ログイン必須) */ + public static final String LIKE_CONFIG_ONLY_ONE = "ONLY_ONE"; + /** UIのテーマの設定のキー */ public static final String CONFIG_KEY_THEMA = "THEMA"; /** Cookieにセットする際のキー:参照履歴 */ diff --git a/src/main/java/org/support/project/knowledge/config/UserConfig.java b/src/main/java/org/support/project/knowledge/config/UserConfig.java new file mode 100644 index 000000000..6c50a7b75 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/config/UserConfig.java @@ -0,0 +1,17 @@ +package org.support.project.knowledge.config; + +/** ユーザー設定(USER_CONFIGSテーブル)の設定キーを管理 */ +public class UserConfig { + public static final String REQUEST_USER_CONFIG_KEY = "REQUEST_USER_CONFIG_KEY"; + + public static final String DEFAULT_PUBLIC_FLAG = "DEFAULT_PUBLIC_FLAG"; + public static final String DEFAULT_TARGET = "DEFAULT_TARGET"; + public static final String POINT = "POINT"; + + public static final String TIMEZONE = "TIMEZONE"; + public static final String TIME_ZONE_OFFSET = "TIME_ZONE_OFFSET"; + public static final String THEMA = "THEMA"; + public static final String HIGHLIGHT = "HIGHLIGHT"; + + +} diff --git a/src/main/java/org/support/project/knowledge/control/Control.java b/src/main/java/org/support/project/knowledge/control/Control.java index 6d7a6f147..79cf3f7ad 100644 --- a/src/main/java/org/support/project/knowledge/control/Control.java +++ b/src/main/java/org/support/project/knowledge/control/Control.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.TimeZone; import javax.servlet.http.HttpServletRequest; @@ -13,13 +14,20 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.log.LogLevel; import org.support.project.common.util.HtmlUtils; +import org.support.project.common.util.StringUtils; import org.support.project.di.DI; import org.support.project.di.Instance; +import org.support.project.knowledge.config.UserConfig; import org.support.project.knowledge.dao.NotifyConfigsDao; import org.support.project.knowledge.entity.NotifyConfigsEntity; +import org.support.project.knowledge.vo.UserConfigs; +import org.support.project.web.bean.LoginedUser; import org.support.project.web.boundary.ForwardBoundary; import org.support.project.web.common.HttpUtil; +import org.support.project.web.logic.DateConvertLogic; +import org.support.project.web.logic.NotificationLogic; import org.support.project.web.logic.SanitizingLogic; +import org.support.project.web.util.JspUtil; @DI(instance = Instance.Prototype) public abstract class Control extends org.support.project.web.control.Control { @@ -30,6 +38,7 @@ public abstract class Control extends org.support.project.web.control.Control { public static final String MSG_SUCCESS = "NOTIFY_MSG_SUCCESS"; public static final String MSG_WARN = "NOTIFY_MSG_WARN"; public static final String MSG_ERROR = "NOTIFY_MSG_ERROR"; + public static final String NOTIFY_UNREAD_COUNT = "NOTIFY_UNREAD_COUNT"; private List infos = null; private List successes = null; @@ -48,6 +57,19 @@ public void setRequest(HttpServletRequest request) { request.setAttribute(MSG_SUCCESS, successes); request.setAttribute(MSG_WARN, warns); request.setAttribute(MSG_ERROR, errors); + + // 通知の件数を取得 + if (getLoginedUser() != null) { + try { + Integer count = NotificationLogic.get().countUnRead(getLoginUserId()); + if (count == null) { + count = 0; + } + request.setAttribute(NOTIFY_UNREAD_COUNT, count); + } catch (Exception e) { + LOG.warn("Error on get user notification count. " + e.getClass().getSimpleName()); + } + } } protected String getResource(String key) { @@ -168,5 +190,29 @@ private boolean flagCheck(Integer check) { } return false; } + + protected UserConfigs getUserConfigs() { + UserConfigs userConfigs = (UserConfigs) getRequest().getAttribute(UserConfig.REQUEST_USER_CONFIG_KEY); + if (userConfigs == null) { + userConfigs = new UserConfigs(); + } + LoginedUser login = getLoginedUser(); + if (login != null) { + userConfigs.setLocale(login.getLocale()); + } else { + userConfigs.setLocale(getLocale()); + } + + if (userConfigs.getTimezone().equals("UTC")) { + String offset = HttpUtil.getCookie(getRequest(), JspUtil.TIME_ZONE_OFFSET); + if (StringUtils.isInteger(offset)) { + int off = Integer.parseInt(offset); + userConfigs.setTimezoneOffset(off); + TimeZone zone = DateConvertLogic.get().getTimezone(getLocale(), off); + userConfigs.setTimezone(zone.getDisplayName()); + } + } + return userConfigs; + } } diff --git a/src/main/java/org/support/project/knowledge/control/admin/AggregateControl.java b/src/main/java/org/support/project/knowledge/control/admin/AggregateControl.java new file mode 100644 index 000000000..30464ea17 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/admin/AggregateControl.java @@ -0,0 +1,10 @@ +package org.support.project.knowledge.control.admin; + +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.control.Control; + +@DI(instance = Instance.Prototype) +public class AggregateControl extends Control { + +} diff --git a/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java b/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java index 8e286a968..e75525723 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java @@ -21,10 +21,12 @@ import org.support.project.web.dao.MailConfigsDao; import org.support.project.web.dao.SystemAttributesDao; import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.dao.SystemsDao; import org.support.project.web.entity.LdapConfigsEntity; import org.support.project.web.entity.MailConfigsEntity; import org.support.project.web.entity.SystemAttributesEntity; import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.entity.SystemsEntity; @DI(instance = Instance.Prototype) public class ConfigControl extends Control { @@ -76,8 +78,7 @@ public Boundary save() { String type = getParam("userAddType"); String notify = getParam("userAddNotify"); // メール送信の場合、メールの設定が完了しているかチェック - if ((type != null && type.equals(SystemConfig.USER_ADD_TYPE_VALUE_MAIL)) - || (notify != null && notify.equals(SystemConfig.USER_ADD_NOTIFY_ON))) { + if (type != null && type.equals(SystemConfig.USER_ADD_TYPE_VALUE_MAIL)) { MailConfigsDao mailConfigsDao = MailConfigsDao.get(); MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); if (mailConfigsEntity == null) { @@ -135,6 +136,16 @@ public Boundary system() { setAttribute("uploadMaxMBSize", "10"); // default } + config = dao.selectOnKey(SystemConfig.LIKE_CONFIG, AppConfig.get().getSystemName()); + if (config != null) { + setAttribute("like_config", config.getConfigValue()); + } + + SystemsEntity entity = SystemsDao.get().selectOnKey(AppConfig.get().getSystemName()); + if (entity != null) { + setAttribute("db_version", entity.getVersion()); + } + return forward("system.jsp"); } @@ -191,7 +202,14 @@ public Boundary save_params() { config = new SystemConfigsEntity(SystemConfig.UPLOAD_MAX_MB_SIZE, AppConfig.get().getSystemName()); config.setConfigValue(uploadMaxMBSize); dao.save(config); - + + String like_config = getParam("like_config"); + if (StringUtils.isNotEmpty(like_config)) { + config = new SystemConfigsEntity(SystemConfig.LIKE_CONFIG, AppConfig.get().getSystemName()); + config.setConfigValue(like_config); + dao.save(config); + } + String successMsg = "message.success.save"; setResult(successMsg, errors); diff --git a/src/main/java/org/support/project/knowledge/control/api/AttachControl.java b/src/main/java/org/support/project/knowledge/control/api/AttachControl.java index 4ac6ecaf8..38fad5617 100644 --- a/src/main/java/org/support/project/knowledge/control/api/AttachControl.java +++ b/src/main/java/org/support/project/knowledge/control/api/AttachControl.java @@ -14,7 +14,7 @@ public class AttachControl extends ApiControl { /** ログ */ private static final Log LOG = LogFactory.getLog(AttachControl.class); - @Get(path="api/attachments") + @Get(path="api/attachments", publishToken="") public Boundary index() { return get(); } diff --git a/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java b/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java index 52e97db82..902dc9309 100644 --- a/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java +++ b/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java @@ -22,14 +22,13 @@ import org.support.project.web.control.ApiControl; import org.support.project.web.control.service.Get; import org.support.project.web.entity.GroupsEntity; -import org.support.project.web.entity.UsersEntity; @DI(instance = Instance.Prototype) public class GroupsControl extends ApiControl { /** * List groups */ - @Get(path="api/groups") + @Get(path="api/groups", publishToken="") public Boundary index() { return get(); } diff --git a/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java b/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java index 5ef8d6778..e76bbb1e4 100644 --- a/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java +++ b/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java @@ -32,7 +32,7 @@ public class KnowledgesControl extends ApiControl { /** ログ */ private static Log LOG = LogFactory.getLog(ControlManagerFilter.class); - @Get(path="api/knowledges") + @Get(path="api/knowledges", publishToken="") public Boundary index() { return get(); } @@ -71,7 +71,7 @@ public Boundary getSingle(String id) { /** * Post knowledges */ - @Post(path="api/knowledges", checkReferer=false) + @Post(path="api/knowledges", checkReferer=false, subscribeToken="") public Boundary post() { try { KnowledgeDetail data = getJsonObject(KnowledgeDetail.class); @@ -91,7 +91,7 @@ public Boundary post() { /** * Put knowledges */ - @Put(path="api/knowledges", checkReferer=false) + @Put(path="api/knowledges", checkReferer=false, subscribeToken="") public Boundary put() { try { Long id = getPathLong(); @@ -114,7 +114,7 @@ public Boundary put() { /** * Delete knowledges */ - @Delete(path="api/knowledges", checkReferer=false) + @Delete(path="api/knowledges", checkReferer=false, subscribeToken="") public Boundary delete() { try { Long id = getPathLong(); diff --git a/src/main/java/org/support/project/knowledge/control/api/SampleControl.java b/src/main/java/org/support/project/knowledge/control/api/SampleControl.java index b73af7b5d..5611fb8bd 100644 --- a/src/main/java/org/support/project/knowledge/control/api/SampleControl.java +++ b/src/main/java/org/support/project/knowledge/control/api/SampleControl.java @@ -12,7 +12,7 @@ public class SampleControl extends Control { /** * サンプル */ - @Get(path="api/sample") + @Get(path="api/sample", publishToken="") public Boundary index() { Msg msg = new Msg("Hi, " + getLoginedUser().getLoginUser().getUserName() + ", this is api sample."); return send(msg); diff --git a/src/main/java/org/support/project/knowledge/control/api/UsersControl.java b/src/main/java/org/support/project/knowledge/control/api/UsersControl.java index 0013a42fc..06f140f13 100644 --- a/src/main/java/org/support/project/knowledge/control/api/UsersControl.java +++ b/src/main/java/org/support/project/knowledge/control/api/UsersControl.java @@ -24,7 +24,7 @@ public class UsersControl extends ApiControl { /** * List users */ - @Get(path="api/users") + @Get(path="api/users", publishToken="") public Boundary index() { return get(); } diff --git a/src/main/java/org/support/project/knowledge/control/open/AccountControl.java b/src/main/java/org/support/project/knowledge/control/open/AccountControl.java index 67b1c1aa9..3208f3bf2 100644 --- a/src/main/java/org/support/project/knowledge/control/open/AccountControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/AccountControl.java @@ -21,12 +21,18 @@ import org.support.project.knowledge.entity.AccountImagesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.TemplateMastersEntity; +import org.support.project.knowledge.logic.AccountLogic; import org.support.project.knowledge.logic.IdenticonLogic; import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.logic.activity.ActivityLogic; import org.support.project.knowledge.vo.AccountInfo; +import org.support.project.knowledge.vo.ActivityHistory; +import org.support.project.knowledge.vo.ContributionPointHistory; import org.support.project.knowledge.vo.StockKnowledge; import org.support.project.web.boundary.Boundary; import org.support.project.web.control.service.Get; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.UsersEntity; import org.support.project.web.exception.InvalidParamException; @DI(instance = Instance.Prototype) @@ -93,6 +99,7 @@ public Boundary info() throws Exception { } List knowledges = KnowledgeLogic.get().showKnowledgeOnUser(userId, getLoginedUser(), offset * PAGE_LIMIT, PAGE_LIMIT); List stocks = KnowledgeLogic.get().setStockInfo(knowledges, getLoginedUser()); + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); setAttribute("knowledges", stocks); int previous = offset - 1; @@ -110,7 +117,58 @@ public Boundary info() throws Exception { } setAttribute("templates", templates); + long point = AccountLogic.get().getPoint(userId); + setAttribute("point", point); + + return forward("account.jsp"); } + + @Get + public Boundary cp() throws Exception { + Integer userId = getPathInteger(-1); + UsersEntity account = UsersDao.get().selectOnKey(userId); + if (account == null) { + return send(HttpStatus.SC_NOT_FOUND, "NOT FOUND"); + } + List list = ActivityLogic.get().getUserPointHistoriesByDate(userId, getUserConfigs()); + return send(list); + } + + @Get + public Boundary knowledge() throws Exception { + Integer userId = getPathInteger(-1); + UsersEntity account = UsersDao.get().selectOnKey(userId); + if (account == null) { + return send(HttpStatus.SC_NOT_FOUND, "NOT FOUND"); + } + // そのユーザが登録したナレッジを取得 + int offset = 0; + if (StringUtils.isInteger(getParam("offset"))) { + offset = getParam("offset", Integer.class); + } + List knowledges = KnowledgeLogic.get().showKnowledgeOnUser(userId, getLoginedUser(), offset * PAGE_LIMIT, PAGE_LIMIT); + List stocks = KnowledgeLogic.get().setStockInfo(knowledges, getLoginedUser()); + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); + return send(stocks); + } + + @Get + public Boundary activity() throws Exception { + Integer userId = getPathInteger(-1); + UsersEntity account = UsersDao.get().selectOnKey(userId); + if (account == null) { + return send(HttpStatus.SC_NOT_FOUND, "NOT FOUND"); + } + int limit = 20; + int offset = 0; + if (StringUtils.isInteger(getParam("offset"))) { + offset = getParam("offset", Integer.class); + } + List list = ActivityLogic.get().getUserPointHistoriese(userId, limit, offset, getUserConfigs()); + setSendEscapeHtml(false); + return send(list); + } + } diff --git a/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java b/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java index 06449e903..855d7e708 100644 --- a/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java @@ -2,14 +2,13 @@ import org.support.project.di.DI; import org.support.project.di.Instance; -import org.support.project.knowledge.control.Control; import org.support.project.web.bean.Msg; import org.support.project.web.boundary.Boundary; import org.support.project.web.control.service.Get; import org.support.project.web.exception.InvalidParamException; @DI(instance = Instance.Prototype) -public class IntervalControl extends Control { +public class IntervalControl extends org.support.project.web.control.Control { @Get public Boundary access() throws InvalidParamException { diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index 40ccb4300..461ff938a 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -11,6 +11,7 @@ import org.support.project.common.exception.ParseException; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.StringUtils; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -23,6 +24,7 @@ import org.support.project.knowledge.dao.KnowledgeHistoriesDao; import org.support.project.knowledge.dao.KnowledgeItemValuesDao; import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.LikeCommentsDao; import org.support.project.knowledge.dao.LikesDao; import org.support.project.knowledge.dao.StocksDao; import org.support.project.knowledge.dao.TagsDao; @@ -32,6 +34,7 @@ import org.support.project.knowledge.entity.KnowledgeHistoriesEntity; import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.LikeCommentsEntity; import org.support.project.knowledge.entity.LikesEntity; import org.support.project.knowledge.entity.StocksEntity; import org.support.project.knowledge.entity.TagsEntity; @@ -42,12 +45,15 @@ import org.support.project.knowledge.logic.GroupLogic; import org.support.project.knowledge.logic.KeywordLogic; import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.logic.LikeLogic; import org.support.project.knowledge.logic.MarkdownLogic; import org.support.project.knowledge.logic.TagLogic; import org.support.project.knowledge.logic.TargetLogic; import org.support.project.knowledge.logic.TemplateLogic; import org.support.project.knowledge.logic.TimeZoneLogic; import org.support.project.knowledge.logic.UploadedFileLogic; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; import org.support.project.knowledge.vo.LikeCount; import org.support.project.knowledge.vo.ListData; import org.support.project.knowledge.vo.MarkDown; @@ -186,18 +192,22 @@ public Boundary view() throws InvalidParamException, ParseException { for (CommentsEntity commentsEntity : comments) { MarkDown markDown2 = MarkdownLogic.get().markdownToHtml(commentsEntity.getComment()); commentsEntity.setComment(markDown2.getHtml()); + + Long likeCount = LikeCommentsDao.get().selectOnCommentNo(commentsEntity.getCommentNo()); + commentsEntity.setLikeCount(likeCount); } setAttribute("comments", comments); // 表示するグループを取得 // List groups = GroupLogic.get().selectGroupsOnKnowledgeId(knowledgeId); - List groups = TargetLogic.get().selectTargetsOnKnowledgeId(knowledgeId); + List groups = TargetLogic.get().selectTargetsViewOnKnowledgeId(knowledgeId, loginedUser); setAttribute("groups", groups); // 編集権限 - List editors = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId); + List editors = TargetLogic.get().selectEditorsViewOnKnowledgeId(knowledgeId, loginedUser); setAttribute("editors", editors); - boolean edit = knowledgeLogic.isEditor(loginedUser, entity, editors); + List editors2 = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId); + boolean edit = knowledgeLogic.isEditor(loginedUser, entity, editors2); setAttribute("edit", edit); ArrayList knowledgeIds = new ArrayList(); @@ -210,6 +220,10 @@ public Boundary view() throws InvalidParamException, ParseException { List stocks = StocksDao.get().selectStockOnKnowledge(entity, loginedUser); setAttribute("stocks", stocks); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_SHOW, getLoginedUser(), DateUtils.now(), entity); + long point = KnowledgesDao.get().selectPoint(entity.getKnowledgeId()); + setAttribute("point", point); + return forward("view.jsp"); } @@ -310,7 +324,7 @@ public Boundary list() throws Exception { // ログインユーザ情報を最新化 // TODO 毎回最新化するのは、パフォーマンスが悪い?グループ情報が更新になった場合に、影響があるユーザの一覧を保持しておき、 // そのユーザのみを更新した方が良いかも。いったんは、ナレッジの一覧を表示する際に、毎回更新してみる(それほど負荷が高くなさそうなので) - super.updateLoginInfo(); + updateLoginInfo(); // 共通処理呼の表示条件の保持の呼び出し setViewParam(); @@ -470,6 +484,7 @@ public Boundary list() throws Exception { } List stocks = knowledgeLogic.setStockInfo(knowledges, loginedUser); + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); setAttribute("knowledges", stocks); LOG.trace("検索終了"); @@ -489,7 +504,7 @@ public Boundary list() throws Exception { } /** - * 閲覧履歴の表示 + * イベント一覧 * * @return * @throws InvalidParamException @@ -516,6 +531,7 @@ public Boundary events() throws InvalidParamException { Participations participations = EventsLogic.get().isParticipation(stock.getKnowledgeId(), getLoginUserId()); stock.setParticipations(participations); } + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); setAttribute("knowledges", stocks); } catch (java.text.ParseException e) { return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD REQUEST"); @@ -561,6 +577,7 @@ public Boundary show_history() throws InvalidParamException { } List histories = knowledgeLogic.getKnowledges(historyIds, loginedUser); List stocks = knowledgeLogic.setStockInfo(histories, loginedUser); + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); setAttribute("histories", stocks); LOG.trace("履歴取得完了"); @@ -585,6 +602,7 @@ public Boundary show_popularity() throws InvalidParamException { List list = knowledgeLogic.getPopularityKnowledges(loginedUser, 0, 20); List stocks = knowledgeLogic.setStockInfo(list, loginedUser); + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); setAttribute("popularities", stocks); LOG.trace("取得完了"); // ナレッジの公開先の情報を取得 @@ -623,7 +641,7 @@ public Boundary stocks() throws InvalidParamException { KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); List list = knowledgeLogic.getStocks(loginedUser, offset * PAGE_LIMIT, PAGE_LIMIT, stockid); List stocks = knowledgeLogic.setStockInfo(list, loginedUser); -// setAttribute("stocks", list); + KnowledgeLogic.get().setViewed(stocks, getLoginedUser()); setAttribute("popularities", stocks); LOG.trace("取得完了"); @@ -635,27 +653,34 @@ public Boundary stocks() throws InvalidParamException { return forward("stocks.jsp"); } - - - - - /** * いいねを押下 * * @return * @throws InvalidParamException */ - @Post + @Post(subscribeToken="knowledge") public Boundary like() throws InvalidParamException { Long knowledgeId = super.getPathLong(Long.valueOf(-1)); - KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); - Long count = knowledgeLogic.addLike(knowledgeId, getLoginedUser()); + Long count = LikeLogic.get().addLike(knowledgeId, getLoginedUser(), getLocale()); LikeCount likeCount = new LikeCount(); likeCount.setKnowledgeId(knowledgeId); likeCount.setCount(count); return send(likeCount); } + /** + * コメントにイイネを押下 + * @return + * @throws InvalidParamException + */ + @Post(subscribeToken="knowledge") + public Boundary likecomment() throws InvalidParamException { + Long commentNo = super.getPathLong(Long.valueOf(-1)); + Long count = LikeLogic.get().addLikeComment(commentNo, getLoginedUser(), getLocale()); + LikeCount likeCount = new LikeCount(); + likeCount.setCount(count); + return send(likeCount); + } /** * タイトルとコンテンツの危険なタグをエスケープした結果を返す @@ -664,7 +689,7 @@ public Boundary like() throws InvalidParamException { * @return * @throws ParseException */ - @Post + @Post(subscribeToken = "") public Boundary escape(KnowledgesEntity entity) throws ParseException { super.setSendEscapeHtml(false); entity.setTitle(sanitize(entity.getTitle())); @@ -679,7 +704,7 @@ public Boundary escape(KnowledgesEntity entity) throws ParseException { * @return * @throws ParseException */ - @Post + @Post(subscribeToken = "") public Boundary marked(KnowledgesEntity entity) throws ParseException { super.setSendEscapeHtml(false); entity.setTitle(sanitize(entity.getTitle())); @@ -764,6 +789,46 @@ public Boundary likes() throws InvalidParamException { return forward("likes.jsp"); } + + /** + * いいねを押したユーザを一覧表示(コメントに対し) + * + * @return + * @throws InvalidParamException + */ + @Get + public Boundary likecomments() throws InvalidParamException { + // 共通処理呼の表示条件の保持の呼び出し + setViewParam(); + + Long commentNo = super.getPathLong(Long.valueOf(-1)); + CommentsEntity comment = CommentsDao.get().selectOnKey(commentNo); + if (comment == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); + } + setAttribute("knowledgeId", comment.getKnowledgeId()); + setAttribute("commentNo", comment.getKnowledgeId()); + + Integer page = 0; + String p = getParamWithDefault("page", ""); + if (StringUtils.isInteger(p)) { + page = Integer.parseInt(p); + } + + List likes = LikeCommentsDao.get().selectOnCommentNo(commentNo, page * PAGE_LIMIT, PAGE_LIMIT); + setAttribute("likes", likes); + + int previous = page - 1; + if (previous < 0) { + previous = 0; + } + setAttribute("page", page); + setAttribute("previous", previous); + setAttribute("next", page + 1); + + return forward("likes.jsp"); + } + /** * 編集履歴の表示 * @@ -916,4 +981,5 @@ public Boundary items() throws ParseException { return super.send(listdata); } + } diff --git a/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java b/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java index e31a0d33c..ae41653b2 100644 --- a/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java @@ -5,6 +5,7 @@ import java.util.List; import org.support.project.common.bean.ValidateError; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.StringUtils; import org.support.project.common.validate.Validator; import org.support.project.common.validate.ValidatorFactory; @@ -91,7 +92,7 @@ public Boundary init() throws InvalidParamException { return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } - long now = new Date().getTime(); + long now = DateUtils.now().getTime(); if (now - resetsEntity.getInsertDatetime().getTime() > 1000 * 60 * 60) { return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } @@ -113,7 +114,7 @@ public Boundary change() { if (resetsEntity == null) { return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } - long now = new Date().getTime(); + long now = DateUtils.now().getTime(); if (now - resetsEntity.getInsertDatetime().getTime() > 1000 * 60 * 60) { return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } diff --git a/src/main/java/org/support/project/knowledge/control/open/SignupControl.java b/src/main/java/org/support/project/knowledge/control/open/SignupControl.java index 7fb8e8ddf..ff1f53391 100644 --- a/src/main/java/org/support/project/knowledge/control/open/SignupControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/SignupControl.java @@ -6,6 +6,7 @@ import org.support.project.aop.Aspect; import org.support.project.common.bean.ValidateError; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.StringUtils; import org.support.project.common.validate.Validator; import org.support.project.common.validate.ValidatorFactory; @@ -15,7 +16,10 @@ import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; import org.support.project.knowledge.control.Control; +import org.support.project.knowledge.logic.KnowledgeAuthenticationLogic; import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.notification.AcceptCheckUserNotification; +import org.support.project.knowledge.logic.notification.AddUserNotification; import org.support.project.web.bean.LoginedUser; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; @@ -32,7 +36,6 @@ import org.support.project.web.entity.UsersEntity; import org.support.project.web.logic.AuthenticationLogic; import org.support.project.web.logic.UserLogic; -import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl; @DI(instance = Instance.Prototype) public class SignupControl extends Control { @@ -81,7 +84,7 @@ public Boundary save() { ProvisionalRegistrationsDao dao = ProvisionalRegistrationsDao.get(); List check = dao.selectOnUserKey(getParam("userKey")); if (!check.isEmpty()) { - long now = new Date().getTime(); + long now = DateUtils.now().getTime(); for (ProvisionalRegistrationsEntity entity : check) { if (now - entity.getInsertDatetime().getTime() > 1000 * 60 * 60) { // 無効なものなので、削除 @@ -116,8 +119,7 @@ public Boundary save() { // 仮登録を行う ProvisionalRegistrationsEntity entity = addProvisionalRegistration(); // 管理者へメール通知 - MailLogic mailLogic = MailLogic.get(); - mailLogic.sendNotifyAcceptUser(entity); + AcceptCheckUserNotification.get().sendNotifyAcceptUser(entity); return forward("provisional_registration.jsp"); } @@ -133,7 +135,7 @@ public Boundary save() { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) private ProvisionalRegistrationsEntity addProvisionalRegistration() { ProvisionalRegistrationsEntity entity = super.getParams(ProvisionalRegistrationsEntity.class); - String id = UUID.randomUUID().toString() + "-" + new Date().getTime() + "-" + UUID.randomUUID().toString(); + String id = UUID.randomUUID().toString() + "-" + DateUtils.now() + "-" + UUID.randomUUID().toString(); entity.setId(id); ProvisionalRegistrationsDao dao = ProvisionalRegistrationsDao.get(); // 既に仮登録が行われたユーザ(メールアドレス)でも、再度仮登録できる @@ -154,13 +156,12 @@ private void addUser() { user = UserLogic.get().insert(user, roles); setAttributeOnProperty(user); - // 管理者へユーザが追加されたことを通知 - MailLogic mailLogic = MailLogic.get(); - mailLogic.sendNotifyAddUser(user); + // 管理者にユーザが追加されたことを通知 + AddUserNotification.get().sendNotifyAddUser(user); // ログイン処理 - AuthenticationLogic logic = Container.getComp(DefaultAuthenticationLogicImpl.class); - logic.setSession(user.getUserKey(), getRequest()); + AuthenticationLogic logic = Container.getComp(KnowledgeAuthenticationLogic.class); + logic.setSession(user.getUserKey(), getRequest(), getResponse()); } /** @@ -212,7 +213,7 @@ public Boundary activate() { return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } - long now = new Date().getTime(); + long now = DateUtils.now().getTime(); if (now - entity.getInsertDatetime().getTime() > 1000 * 60 * 60) { return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } @@ -221,13 +222,12 @@ public Boundary activate() { UsersEntity user = UserLogic.get().activate(entity); // 管理者へユーザが追加されたことを通知 if (user != null) { - MailLogic mailLogic = MailLogic.get(); - mailLogic.sendNotifyAddUser(user); - + // 管理者にユーザが追加されたことを通知 + AddUserNotification.get().sendNotifyAddUser(user); } // ログイン処理 - AuthenticationLogic logic = Container.getComp(DefaultAuthenticationLogicImpl.class); - logic.setSession(entity.getUserKey(), getRequest()); + AuthenticationLogic logic = Container.getComp(KnowledgeAuthenticationLogic.class); + logic.setSession(entity.getUserKey(), getRequest(), getResponse()); addMsgInfo("knowledge.signup.done"); return devolution(HttpMethod.get, "Index/index"); diff --git a/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java b/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java index 18970dab0..c58f74e8d 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java @@ -16,8 +16,10 @@ import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.config.UserConfig; import org.support.project.knowledge.control.Control; import org.support.project.knowledge.logic.AccountLogic; +import org.support.project.knowledge.logic.KnowledgeAuthenticationLogic; import org.support.project.knowledge.logic.TargetLogic; import org.support.project.knowledge.logic.UserLogicEx; import org.support.project.knowledge.vo.UploadFile; @@ -38,7 +40,6 @@ import org.support.project.web.entity.UsersEntity; import org.support.project.web.exception.InvalidParamException; import org.support.project.web.logic.AuthenticationLogic; -import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl; @DI(instance = Instance.Prototype) public class AccountControl extends Control { @@ -184,7 +185,7 @@ public Boundary delete() throws Exception { UserLogicEx.get().withdrawal(getLoginUserId(), knowledgeRemove, HttpUtil.getLocale(getRequest())); // セッションを破棄 - AuthenticationLogic authenticationLogic = Container.getComp(DefaultAuthenticationLogicImpl.class); + AuthenticationLogic authenticationLogic = Container.getComp(KnowledgeAuthenticationLogic.class); authenticationLogic.clearSession(getRequest()); addMsgInfo("knowledge.account.delete"); @@ -315,11 +316,11 @@ public Boundary confirm_mail() throws InvalidParamException { @Get(publishToken = "knowledge") public Boundary targets() { UserConfigsEntity publicFlag = UserConfigsDao.get().physicalSelectOnKey( - "DEFAULT_PUBLIC_FLAG", AppConfig.get().getSystemName(), getLoginUserId()); + UserConfig.DEFAULT_PUBLIC_FLAG, AppConfig.get().getSystemName(), getLoginUserId()); if (publicFlag != null) { setAttribute("publicFlag", publicFlag.getConfigValue()); UserConfigsEntity targets = UserConfigsDao.get().physicalSelectOnKey( - "DEFAULT_TARGET", AppConfig.get().getSystemName(), getLoginUserId()); + UserConfig.DEFAULT_TARGET, AppConfig.get().getSystemName(), getLoginUserId()); if (targets != null) { if (StringUtils.isNotEmpty(targets.getConfigValue())) { String[] targetKeys = targets.getConfigValue().split(","); @@ -336,11 +337,11 @@ public Boundary targets() { public Boundary savetargets() { String publicFlag = getParam("publicFlag"); String viewers = getParam("viewers"); - UserConfigsEntity publicFlagEntiry = new UserConfigsEntity("DEFAULT_PUBLIC_FLAG", AppConfig.get().getSystemName(), getLoginUserId()); + UserConfigsEntity publicFlagEntiry = new UserConfigsEntity(UserConfig.DEFAULT_PUBLIC_FLAG, AppConfig.get().getSystemName(), getLoginUserId()); publicFlagEntiry.setConfigValue(publicFlag); UserConfigsDao.get().save(publicFlagEntiry); - UserConfigsEntity targetsEntity = new UserConfigsEntity("DEFAULT_TARGET", AppConfig.get().getSystemName(), getLoginUserId()); + UserConfigsEntity targetsEntity = new UserConfigsEntity(UserConfig.DEFAULT_TARGET, AppConfig.get().getSystemName(), getLoginUserId()); targetsEntity.setConfigValue(viewers); List results = targetsEntity.validate(); diff --git a/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java b/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java index b5c189bef..b05664406 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java @@ -40,7 +40,7 @@ public Boundary index() { * 指定のユーザのLdap認証設定を設定する * @return */ - @Get + @Get(publishToken="csrf") public Boundary config() { String key = getParam("key"); if (StringUtils.isEmpty(key)) { @@ -67,7 +67,7 @@ public Boundary config() { return forward("config.jsp"); } - @Post + @Post(subscribeToken="csrf") public Boundary connect() { String key = getParam("key"); if (StringUtils.isEmpty(key)) { @@ -133,7 +133,7 @@ public Boundary connect() { } } - @Post + @Post(subscribeToken="csrf") public Boundary disconnect() { String key = getParam("key"); if (StringUtils.isEmpty(key)) { @@ -153,7 +153,7 @@ public Boundary disconnect() { return index(); } - @Post + @Post(subscribeToken="csrf") public Boundary update() { String key = getParam("key"); if (StringUtils.isEmpty(key)) { diff --git a/src/main/java/org/support/project/knowledge/control/protect/EventControl.java b/src/main/java/org/support/project/knowledge/control/protect/EventControl.java index c783d28e9..51cce0c80 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/EventControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/EventControl.java @@ -1,9 +1,13 @@ package org.support.project.knowledge.control.protect; +import org.support.project.common.util.DateUtils; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.control.Control; +import org.support.project.knowledge.dao.KnowledgesDao; import org.support.project.knowledge.logic.EventsLogic; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; import org.support.project.web.bean.LabelValue; import org.support.project.web.boundary.Boundary; import org.support.project.web.control.service.Delete; @@ -18,7 +22,7 @@ public class EventControl extends Control { * @return * @throws InvalidParamException */ - @Put + @Put(subscribeToken = "knowledge") public Boundary participation() throws InvalidParamException { Long knowledgeId = getPathLong(); Boolean result = EventsLogic.get().participation(knowledgeId, getLoginUserId()); @@ -29,6 +33,10 @@ public Boundary participation() throws InvalidParamException { } else { labelValue.setLabel(getResource("knowledge.view.msg.wait.cansel")); } + + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_EVENT_ADD, getLoginedUser(), DateUtils.now(), + KnowledgesDao.get().selectOnKey(knowledgeId)); + return send(labelValue); } /** @@ -36,10 +44,14 @@ public Boundary participation() throws InvalidParamException { * @return * @throws InvalidParamException */ - @Delete + @Delete(subscribeToken = "knowledge") public Boundary nonparticipation() throws InvalidParamException { Long knowledgeId = getPathLong(); EventsLogic.get().removeParticipation(knowledgeId, getLoginUserId()); + + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_EVENT_DELETE, getLoginedUser(), DateUtils.now(), + KnowledgesDao.get().selectOnKey(knowledgeId)); + return send(getResource("knowledge.view.msg.participate.delete")); } diff --git a/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java b/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java index 18ca6139e..2b372511a 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java @@ -16,7 +16,6 @@ import org.support.project.knowledge.logic.GroupLogic; import org.support.project.knowledge.vo.GroupUser; import org.support.project.knowledge.vo.StringList; -import org.support.project.web.annotation.Auth; import org.support.project.web.bean.LabelValue; import org.support.project.web.bean.LoginedUser; import org.support.project.web.bean.MessageResult; @@ -534,13 +533,17 @@ public Boundary extractEmail() { /** * メールアドレスの一覧から、グループのユーザを一括登録 - * (メールアドレスの存在チェックができてしまうので、いったん管理者だけの機能にする) * @return */ @Post(subscribeToken = "knowledge") - @Auth(roles = "admin") public Boundary addUsersOnEmail() { Integer groupId = getParam("group", Integer.class); + GroupsEntity group = GroupLogic.get().getEditAbleGroup(groupId, getLoginedUser()); + if (group == null) { + // 編集可能なグループが存在しない + return sendError(HttpStatus.SC_403_FORBIDDEN, ""); + } + String emails = getParam("emails"); String[] mails = emails.split("\n"); MessageResult result = new MessageResult(MessageStatus.Success, HttpStatus.SC_200_OK, "", ""); @@ -571,10 +574,4 @@ public Boundary addUsersOnEmail() { return send(result); } - - - - - - } diff --git a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java index b030278c0..ca718c00c 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java @@ -12,12 +12,14 @@ import org.support.project.common.exception.ParseException; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.PropertyUtil; import org.support.project.common.util.StringUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.UserConfig; import org.support.project.knowledge.control.KnowledgeControlBase; import org.support.project.knowledge.dao.CommentsDao; import org.support.project.knowledge.dao.DraftKnowledgesDao; @@ -37,6 +39,8 @@ import org.support.project.knowledge.logic.TargetLogic; import org.support.project.knowledge.logic.TemplateLogic; import org.support.project.knowledge.logic.UploadedFileLogic; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; import org.support.project.knowledge.vo.KnowledgeData; import org.support.project.knowledge.vo.Stock; import org.support.project.knowledge.vo.UploadFile; @@ -100,11 +104,11 @@ public Boundary view_add() { if (getAttribute("publicFlag") == null) { UserConfigsEntity publicFlag = UserConfigsDao.get().physicalSelectOnKey( - "DEFAULT_PUBLIC_FLAG", AppConfig.get().getSystemName(), getLoginUserId()); + UserConfig.DEFAULT_PUBLIC_FLAG, AppConfig.get().getSystemName(), getLoginUserId()); if (publicFlag != null) { setAttribute("publicFlag", publicFlag.getConfigValue()); UserConfigsEntity targets = UserConfigsDao.get().physicalSelectOnKey( - "DEFAULT_TARGET", AppConfig.get().getSystemName(), getLoginUserId()); + UserConfig.DEFAULT_TARGET, AppConfig.get().getSystemName(), getLoginUserId()); if (targets != null) { if (StringUtils.isNotEmpty(targets.getConfigValue())) { String[] targetKeys = targets.getConfigValue().split(","); @@ -149,20 +153,21 @@ public Boundary view_edit() throws InvalidParamException { if (draft != null) { super.setDraftInfo(draft); } else { + // 編集権限チェック + LoginedUser loginedUser = super.getLoginedUser(); + // ナレッジに紐づく添付ファイルを取得 List files = fileLogic.selectOnKnowledgeIdWithoutCommentFiles(knowledgeId, getRequest().getContextPath()); setAttribute("files", files); // 表示するグループを取得 - List groups = TargetLogic.get().selectTargetsOnKnowledgeId(knowledgeId); + List groups = TargetLogic.get().selectTargetsViewOnKnowledgeId(knowledgeId, loginedUser); setAttribute("groups", groups); // 共同編集者 - List editors = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId); + List editors = TargetLogic.get().selectEditorsViewOnKnowledgeId(knowledgeId, loginedUser); setAttribute("editors", editors); - - // 編集権限チェック - LoginedUser loginedUser = super.getLoginedUser(); + boolean edit = knowledgeLogic.isEditor(loginedUser, entity, editors); if (!edit) { setAttribute("edit", false); @@ -209,7 +214,7 @@ private Boundary add(KnowledgesEntity entity) throws Exception, ParseException { LOG.trace("save"); KnowledgesEntity insertedEntity = knowledgeLogic.insert(data, super.getLoginedUser()); - + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, String.valueOf(insertedEntity.getKnowledgeId()), "message.success.insert"); } @@ -278,8 +283,16 @@ private Boundary update(KnowledgesEntity entity) throws Exception { return sendValidateError(errors); } + // 明示的にユーザが、タイムラインの上にもっていきたくないと指定した + if ("true".equals(super.getAttribute("notUpdateTimeline", "false"))) { + data.setDonotUpdateTimeline(true); + } if (!StringUtils.isEmpty(getParam("updateContent")) && getParam("updateContent").toLowerCase().equals("true")) { + // コンテンツの内容が更新されている data.setUpdateContent(true); + if (!data.isDonotUpdateTimeline()) { + data.setNotifyUpdate(true); + } LOG.debug("コンテンツを更新した"); } else { // メタデータのみ更新 @@ -289,13 +302,12 @@ private Boundary update(KnowledgesEntity entity) throws Exception { if (check.getPublicFlag().intValue() == KnowledgeLogic.PUBLIC_FLAG_PRIVATE && check.getPublicFlag().intValue() != data.getKnowledge().getPublicFlag().intValue()) { // まだ通知を一度も出しておらず、かつ、「非公開」になっていたものを、それ以外の区分に変更した場合は、通知を出す - data.setUpdateContent(true); + data.setNotifyUpdate(true); LOG.debug("メタデータのみ更新であったが、非公開から公開などへ変更した"); } } } - - + // 更新実行 KnowledgesEntity updatedEntity = knowledgeLogic.update(data, super.getLoginedUser()); if (data.isUpdateContent()) { @@ -316,6 +328,9 @@ private Boundary update(KnowledgesEntity entity) throws Exception { @Post(subscribeToken = "knowledge", checkReqToken = true) public Boundary save(KnowledgesEntity entity) throws Exception { try { + if (entity.getPoint() == null) { + entity.setPoint(0); // 初期値 + } if (entity.getKnowledgeId() != null && entity.getKnowledgeId() >= 1) { return update(entity); } else { @@ -472,12 +487,9 @@ public Boundary comment() throws Exception { } } setAttribute("comment_files", files); - return super.devolution(HttpMethod.get, "open.Knowledge/view", String.valueOf(knowledgeId)); } - KnowledgeLogic.get().saveComment(knowledgeId, comment, fileNos, getLoginedUser()); - return super.redirect(getRequest().getContextPath() + "/open.knowledge/view/" + knowledgeId + params); } @@ -659,6 +671,7 @@ public Boundary delete_comment() throws Exception { } KnowledgeLogic.get().deleteComment(db, getLoginedUser()); + addMsgSuccess("message.success.delete.target", getResource("label.comment")); setAttribute("comment", null); return devolution(HttpMethod.get, "open.Knowledge/view", String.valueOf(db.getKnowledgeId())); @@ -715,6 +728,9 @@ public Boundary stock() throws IOException, InvalidParamException { dao.physicalDelete(entity); } } + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_STOCK, getLoginedUser(), DateUtils.now(), + KnowledgesDao.get().selectOnKey(knowledgeId)); + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, "saved", "message.success.save"); }; diff --git a/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java b/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java new file mode 100644 index 000000000..02d22b122 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/protect/NotificationControl.java @@ -0,0 +1,91 @@ +package org.support.project.knowledge.control.protect; + +import java.util.List; + +import org.support.project.knowledge.control.Control; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.exception.InvalidParamException; + +public class NotificationControl extends Control { + + @Get(publishToken = "knowledge") + public Boundary list() throws InvalidParamException { + int offset = getPathInteger(0); + boolean all = "true".equals(getAttribute("all", "false")); + List notifications = NotificationLogic.get().getNotification(getLoginedUser(), offset, all); + setAttribute("notifications", notifications); + + int previous = offset - 1; + if (previous < 0) { + previous = 0; + } + setAttribute("offset", offset); + setAttribute("previous", previous); + setAttribute("next", offset + 1); + + return forward("list.jsp"); + } + + @Get + public Boundary view() throws InvalidParamException { + long no = getPathLong(new Long(-1)); + NotificationsEntity notification = NotificationLogic.get().load(no, getLoginedUser()); + if (notification == null) { + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + NotificationLogic.get().setStatus(getLoginUserId(), no, NotificationLogic.STATUS_READED); + notification.setStatus(NotificationLogic.STATUS_READED); + setAttributeOnProperty(notification); + setAttribute("no", no); + return forward("view.jsp"); + } + + @Get + public Boundary previous() throws InvalidParamException { + long no = getPathLong(new Long(-1)); + boolean all = "true".equals(getAttribute("all", "false")); + NotificationsEntity notification = NotificationLogic.get().previous(no, getLoginedUser(), all); + if (notification == null) { + setAttribute("method", getResource("label.previous")); + setAttribute("no", no); + return forward("not_found.jsp"); + } + no = notification.getNo(); + NotificationLogic.get().setStatus(getLoginUserId(), no, NotificationLogic.STATUS_READED); + notification.setStatus(NotificationLogic.STATUS_READED); + setAttributeOnProperty(notification); + setAttribute("no", no); + return forward("view.jsp"); + } + @Get + public Boundary next() throws InvalidParamException { + long no = getPathLong(new Long(-1)); + boolean all = "true".equals(getAttribute("all", "false")); + NotificationsEntity notification = NotificationLogic.get().next(no, getLoginedUser(), all); + if (notification == null) { + setAttribute("method", getResource("label.next")); + setAttribute("no", no); + return forward("not_found.jsp"); + } + no = notification.getNo(); + NotificationLogic.get().setStatus(getLoginUserId(), no, NotificationLogic.STATUS_READED); + notification.setStatus(NotificationLogic.STATUS_READED); + setAttributeOnProperty(notification); + setAttribute("no", no); + return forward("view.jsp"); + } + + @Post(subscribeToken = "knowledge") + public Boundary markread() { + String no = getAttribute("no", ""); + NotificationLogic.get().markAllAsRead(no, getLoginUserId()); + return send("OK"); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java b/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java index afe817e91..7b5724c01 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java @@ -7,11 +7,13 @@ import org.support.project.common.bean.ValidateError; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.PropertyUtil; import org.support.project.common.util.StringUtils; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.control.admin.TemplateControl; +import org.support.project.knowledge.dao.KnowledgesDao; import org.support.project.knowledge.entity.ItemChoicesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.SurveyAnswersEntity; @@ -23,7 +25,11 @@ import org.support.project.knowledge.entity.TemplateMastersEntity; import org.support.project.knowledge.logic.KnowledgeLogic; import org.support.project.knowledge.logic.SurveyLogic; +import org.support.project.knowledge.logic.TargetLogic; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; import org.support.project.knowledge.vo.SurveyReport; +import org.support.project.web.bean.LabelValue; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.config.MessageStatus; @@ -68,7 +74,8 @@ public Boundary save() throws InstantiationException, IllegalAccessException, JS return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); } KnowledgesEntity knowledge = KnowledgeLogic.get().select(knowledgeId, getLoginedUser()); - if (knowledge == null || !KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledge, null)) { + List editors = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId); + if (knowledge == null || !KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledge, editors)) { return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); } // テンプレートと同じ構造にしているが、アンケートに変換して保存する @@ -133,12 +140,24 @@ public Boundary list() throws InvalidParamException { * @return * @throws InvalidParamException */ - @Get + @Get(publishToken = "survey") public Boundary load() throws InvalidParamException { Long id = super.getPathLong(new Long(-1)); SurveysEntity entity = SurveyLogic.get().loadSurvey(id, getLoginUserId()); if (entity == null) { - return sendError(404, null); + entity = new SurveysEntity(); + entity.setDescription(""); + entity.setItems(new ArrayList<>()); + entity.setExist(false); + } else { + entity.setExist(true); + } + KnowledgesEntity knowledge = KnowledgeLogic.get().select(id, getLoginedUser()); + List editors = TargetLogic.get().selectEditorsOnKnowledgeId(id); + if (knowledge != null && KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledge, editors)) { + entity.setEditable(true); + } else { + entity.setEditable(false); } return send(entity); } @@ -148,7 +167,7 @@ public Boundary load() throws InvalidParamException { * @return * @throws InvalidParamException */ - @Delete + @Delete(subscribeToken = "survey") public Boundary delete() throws InvalidParamException { Long id = super.getPathLong(new Long(-1)); SurveyLogic.get().deleteSurvey(id); @@ -167,7 +186,7 @@ public Boundary delete() throws InvalidParamException { * @throws IllegalAccessException * @throws InstantiationException */ - @Post(subscribeToken = "knowledge", checkReqToken = true) + @Post(subscribeToken = "survey", checkReqToken = true) public Boundary answer() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { String id = getParam("knowledgeId"); if (!StringUtils.isLong(id)) { @@ -222,6 +241,8 @@ public Boundary answer() throws InstantiationException, IllegalAccessException, LOG.debug(PropertyUtil.reflectionToString(answer)); } SurveyLogic.get().saveAnswer(answer, getLoginUserId()); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_ANSWER, getLoginedUser(), DateUtils.now(), + KnowledgesDao.get().selectOnKey(knowledgeId)); // メッセージ送信 return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, "saved", "message.success.save"); diff --git a/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java b/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java index 53a7734ea..83ae702e0 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java @@ -8,7 +8,6 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; -import org.support.project.common.util.DateUtils; import org.support.project.common.util.RandomUtil; import org.support.project.common.util.StringUtils; import org.support.project.di.DI; @@ -33,8 +32,9 @@ private DateFormat gateDayFormat() { /** * 現在のTokenの状態を見る */ - @Get + @Get(publishToken = "csrf") public Boundary index() { + LOG.trace("access to index"); String expires = ""; TokensEntity entity = TokensDao.get().selectOnUserId(getLoginUserId()); if (entity == null) { @@ -52,8 +52,9 @@ public Boundary index() { /** * Tokenの発行/更新 */ - @Post + @Post(subscribeToken = "csrf") public Boundary save() { + LOG.trace("access to save"); String expires = getParam("expires"); if (StringUtils.isEmpty(expires)) { expires = "9999-12-31"; @@ -80,7 +81,7 @@ public Boundary save() { /** * Tokenの削除 */ - @Post + @Post(subscribeToken = "csrf") public Boundary delete() { TokensEntity entity = TokensDao.get().selectOnUserId(getLoginUserId()); if (entity != null) { diff --git a/src/main/java/org/support/project/knowledge/dao/AccountImagesDao.java b/src/main/java/org/support/project/knowledge/dao/AccountImagesDao.java index 8a7111e71..6f24511f7 100644 --- a/src/main/java/org/support/project/knowledge/dao/AccountImagesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/AccountImagesDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -24,6 +25,7 @@ public static AccountImagesDao get() { return Container.getComp(AccountImagesDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public AccountImagesEntity selectOnUserId(Integer userId) { String sql = "SELECT * FROM ACCOUNT_IMAGES WHERE USER_ID = ?"; return executeQuerySingle(sql, AccountImagesEntity.class, userId); diff --git a/src/main/java/org/support/project/knowledge/dao/ActivitiesDao.java b/src/main/java/org/support/project/knowledge/dao/ActivitiesDao.java new file mode 100644 index 000000000..57fa54746 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/ActivitiesDao.java @@ -0,0 +1,96 @@ +package org.support.project.knowledge.dao; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.gen.GenActivitiesDao; +import org.support.project.knowledge.entity.ActivitiesEntity; + +/** + * アクティビティ + */ +@DI(instance = Instance.Singleton) +public class ActivitiesDao extends GenActivitiesDao { + /** ログ */ + private static final Log LOG = LogFactory.getLog(ActivitiesDao.class); + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static ActivitiesDao get() { + return Container.getComp(ActivitiesDao.class); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity select(int userId, int type, String target) { + String sql = "SELECT * FROM ACTIVITIES WHERE USER_ID = ? AND KIND = ? AND TARGET = ?"; + return executeQuerySingle(sql, ActivitiesEntity.class, userId, type, target); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnNos(List activityNos) { + StringBuilder sql = new StringBuilder(); + sql.append("SELECT *, USERS.USER_NAME FROM ACTIVITIES INNER JOIN USERS ON (ACTIVITIES.USER_ID = USERS.USER_ID) "); + sql.append("WHERE ACTIVITY_NO IN ("); + boolean appended = false; + for (@SuppressWarnings("unused") Long no : activityNos) { + if (appended) { + sql.append(", "); + } + sql.append("?"); + appended = true; + } + sql.append(");"); + return executeQueryList(sql.toString(), ActivitiesEntity.class, activityNos.toArray(new Object[0])); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity selectBefore(Integer userId, String target, int... kinds) { + StringBuilder sql = new StringBuilder(); + List params = new ArrayList<>(); + params.add(userId); + params.add(target); + sql.append("SELECT * FROM ACTIVITIES "); + sql.append("WHERE USER_ID = ? AND TARGET = ? AND "); + sql.append("KIND IN ("); + boolean appended = false; + for (int i : kinds) { + if (appended) { + sql.append(", "); + + } + sql.append("?"); + appended = true; + params.add(i); + } + sql.append(") ORDER BY INSERT_DATETIME DESC LIMIT 1 OFFSET 0"); + return executeQuerySingle(sql.toString(), ActivitiesEntity.class, params.toArray(new Object[0])); + } + /** + * 指定のアクティビティの件数を取得 + * @param kind + * @param targetId + * @return + */ + public long selectCountByTarget(int kind, Long targetId) { + String target = String.valueOf(targetId); + String sql = "SELECT COUNT(*) FROM ACTIVITIES WHERE KIND = ? AND TARGET = ?"; + return executeQuerySingle(sql, Long.class, kind, target); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void removeAll() { + LOG.warn("Remove all activities"); + String sql = "DELETE FROM ACTIVITIES"; + executeUpdate(sql); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/BadgesDao.java b/src/main/java/org/support/project/knowledge/dao/BadgesDao.java new file mode 100644 index 000000000..1bd55820f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/BadgesDao.java @@ -0,0 +1,50 @@ +package org.support.project.knowledge.dao; + +import org.support.project.aop.Aspect; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import org.support.project.knowledge.dao.gen.GenBadgesDao; + +/** + * 称号 + */ +@DI(instance = Instance.Singleton) +public class BadgesDao extends GenBadgesDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static BadgesDao get() { + return Container.getComp(BadgesDao.class); + } + + + /** + * ID + */ + private int currentId = 0; + + /** + * Get Next id + * @return next id + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer getNextId() { + String sql = "SELECT MAX(NO) FROM BADGES;"; + Integer integer = executeQuerySingle(sql, Integer.class); + if (integer != null) { + if (currentId < integer) { + currentId = integer; + } + } + currentId++; + return currentId; + } + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/CommentsDao.java b/src/main/java/org/support/project/knowledge/dao/CommentsDao.java index 548eb64c0..1d5f5dba5 100644 --- a/src/main/java/org/support/project/knowledge/dao/CommentsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/CommentsDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -26,6 +27,7 @@ public static CommentsDao get() { return Container.getComp(CommentsDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { StringBuilder builder = new StringBuilder(); builder.append("SELECT COMMENTS.*, UPDATE_USER.USER_NAME AS UPDATE_USER_NAME, INSERT_USER.USER_NAME AS INSERT_USER_NAME FROM COMMENTS "); @@ -42,9 +44,17 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer countOnKnowledgeId(Long knowledgeId) { String sql = "SELECT COUNT(*) FROM COMMENTS WHERE KNOWLEDGE_ID = ? AND DELETE_FLAG = 0 "; return super.executeQuerySingle(sql, Integer.class, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectUniqueUserCountOnKnowledgeId(Long knowledgeId) { + String sql = "SELECT COUNT(*) FROM (" + + "SELECT KNOWLEDGE_ID, INSERT_USER FROM COMMENTS WHERE KNOWLEDGE_ID = ? GROUP BY KNOWLEDGE_ID, INSERT_USER) AS SUBQ"; + return super.executeQuerySingle(sql, Long.class, knowledgeId); + } + } diff --git a/src/main/java/org/support/project/knowledge/dao/DraftItemValuesDao.java b/src/main/java/org/support/project/knowledge/dao/DraftItemValuesDao.java index 4e16779fa..24e5dcd72 100644 --- a/src/main/java/org/support/project/knowledge/dao/DraftItemValuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/DraftItemValuesDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -27,6 +28,7 @@ public static DraftItemValuesDao get() { * @param draftId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int deleteOnDraftId(Long draftId) { String sql = "DELETE FROM DRAFT_ITEM_VALUES WHERE DRAFT_ID = ?"; return super.executeUpdate(sql, draftId); diff --git a/src/main/java/org/support/project/knowledge/dao/DraftKnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/DraftKnowledgesDao.java index b8a38325f..2045e765c 100644 --- a/src/main/java/org/support/project/knowledge/dao/DraftKnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/DraftKnowledgesDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -25,12 +26,13 @@ public static DraftKnowledgesDao get() { return Container.getComp(DraftKnowledgesDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnUser(Integer loginUserId, int limit, int offset) { String sql = "SELECT * FROM DRAFT_KNOWLEDGES WHERE INSERT_USER = ? limit ? offset ?"; return super.executeQueryList(sql, DraftKnowledgesEntity.class, loginUserId, limit, offset); } - + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftKnowledgesEntity selectOnKnowledgeAndUser(Long knowledgeId, Integer loginUserId) { String sql = "SELECT * FROM DRAFT_KNOWLEDGES WHERE INSERT_USER = ? AND KNOWLEDGE_ID = ?"; return super.executeQuerySingle(sql, DraftKnowledgesEntity.class, loginUserId, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/EventsDao.java b/src/main/java/org/support/project/knowledge/dao/EventsDao.java index 33edbfc6a..3ed0ec4a7 100644 --- a/src/main/java/org/support/project/knowledge/dao/EventsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/EventsDao.java @@ -5,6 +5,7 @@ import java.util.Calendar; import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -31,6 +32,7 @@ public static EventsDao get() { return Container.getComp(EventsDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAccessAbleEvents(Calendar start, Calendar end, LoginedUser loginedUser) { String sql; if (loginedUser != null && loginedUser.isAdmin()) { @@ -49,6 +51,7 @@ public List selectAccessAbleEvents(Calendar start, Calendar end, L return executeQueryList(sql, EventsEntity.class, params.toArray(new Object[0])); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) private String addAccessCondition(LoginedUser loginedUser, String sql, List params) { Integer loginuserId = Integer.MIN_VALUE; if (loginedUser != null) { @@ -79,6 +82,7 @@ private String addAccessCondition(LoginedUser loginedUser, String sql, List selectAccessAbleEvents(Calendar start, LoginedUser loginedUser, int limit, int offset) { String sql; if (loginedUser != null && loginedUser.isAdmin()) { diff --git a/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java b/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java index d8b8236cb..439ee8a1c 100644 --- a/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -41,6 +42,7 @@ public static ExGroupsDao get() { * @return */ @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectMyGroup(LoginedUser loginedUser, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExGroupsDao/ExGroupsDao_selectMyGroup.sql"); return executeQueryList(sql, GroupsEntity.class, loginedUser.getUserId(), limit, offset); @@ -56,6 +58,7 @@ public List selectMyGroup(LoginedUser loginedUser, int offset, int * @return */ @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAccessAbleGroups(LoginedUser loginedUser, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExGroupsDao/ExGroupsDao_selectAccessAbleGroups.sql"); return executeQueryList(sql, GroupsEntity.class, loginedUser.getUserId(), limit, offset); @@ -71,6 +74,7 @@ public List selectAccessAbleGroups(LoginedUser loginedUser, int of * @return */ @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKeyword(String keyword, LoginedUser loginedUser, int offset, int limit) { if (loginedUser != null && loginedUser.isAdmin()) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExGroupsDao/ExGroupsDao_selectAdminOnKeyword.sql"); @@ -92,6 +96,7 @@ public List selectOnKeyword(String keyword, LoginedUser loginedUse * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectGroupsWithCount(int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExGroupsDao/ExGroupsDao_selectGroupsWithCount.sql"); return executeQueryList(sql, GroupsEntity.class, limit, offset); @@ -102,6 +107,7 @@ public List selectGroupsWithCount(int offset, int limit) { * @param groupId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectGroupKnowledgeCount(int groupId) { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_GROUPS WHERE GROUP_ID = ?"; return executeQuerySingle(sql, Integer.class, groupId); @@ -111,6 +117,7 @@ public Integer selectGroupKnowledgeCount(int groupId) { * @param groupId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectGroupUserCount(int groupId) { String sql = "SELECT COUNT(*) FROM USER_GROUPS WHERE GROUP_ID = ?"; return executeQuerySingle(sql, Integer.class, groupId); diff --git a/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java b/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java index 1c7476e76..82f4d1dac 100644 --- a/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.knowledge.vo.AccountInfo; import org.support.project.knowledge.vo.GroupUser; @@ -35,6 +36,7 @@ public static ExUsersDao get() { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectGroupUser(Integer groupId, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExUsersDao/selectGroupUser.sql"); return executeQueryList(sql, GroupUser.class, groupId, limit, offset); @@ -45,6 +47,7 @@ public List selectGroupUser(Integer groupId, int offset, int limit) { * * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectNotifyPublicUsers() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql"); return executeQueryList(sql, UsersEntity.class); @@ -58,6 +61,7 @@ public List selectNotifyPublicUsers() { * @param userId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public AccountInfo selectAccountInfoOnKey(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExUsersDao/selectAccountInfoOnKey.sql"); AccountInfo info = executeQuerySingle(sql, AccountInfo.class, userId); diff --git a/src/main/java/org/support/project/knowledge/dao/ItemChoicesDao.java b/src/main/java/org/support/project/knowledge/dao/ItemChoicesDao.java index f22a32bc8..044bd0b00 100644 --- a/src/main/java/org/support/project/knowledge/dao/ItemChoicesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ItemChoicesDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -33,6 +34,7 @@ public static ItemChoicesDao get() { * @param itemNo * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItem(Integer typeId, Integer itemNo) { String sql = "SELECT * FROM ITEM_CHOICES WHERE TYPE_ID = ? AND ITEM_NO = ? AND DELETE_FLAG = 0"; return super.executeQueryList(sql, ItemChoicesEntity.class, typeId, itemNo); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeEditGroupsDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeEditGroupsDao.java index 7c803b2f5..5b7436d83 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeEditGroupsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeEditGroupsDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -23,6 +24,7 @@ public static KnowledgeEditGroupsDao get() { return Container.getComp(KnowledgeEditGroupsDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM KNOWLEDGE_EDIT_GROUPS WHERE KNOWLEDGE_ID = ?"; super.executeUpdate(sql, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeEditUsersDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeEditUsersDao.java index 017206923..b89d67846 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeEditUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeEditUsersDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -23,6 +24,7 @@ public static KnowledgeEditUsersDao get() { return Container.getComp(KnowledgeEditUsersDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM KNOWLEDGE_EDIT_USERS WHERE KNOWLEDGE_ID = ?"; super.executeUpdate(sql, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java index b1c40149e..8bd03f8b0 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java @@ -5,6 +5,7 @@ import java.util.List; import org.support.project.aop.Aspect; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -37,6 +38,7 @@ public static KnowledgeFilesDao get() { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, DRAFT_ID, FILE_NAME, FILE_SIZE, PARSE_STATUS, "); @@ -50,6 +52,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param draftId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnDraftId(Long draftId) { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, DRAFT_ID, FILE_NAME, FILE_SIZE, PARSE_STATUS, "); @@ -63,6 +66,7 @@ public List selectOnDraftId(Long draftId) { /** * キーで1件取得 (ファイルのバイナリは取得しない) */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeFilesEntity selectOnKeyWithoutBinary(Long fileNo) { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, DRAFT_ID, FILE_NAME, FILE_SIZE, PARSE_STATUS, "); @@ -79,12 +83,13 @@ public KnowledgeFilesEntity selectOnKeyWithoutBinary(Long fileNo) { * @param commentNo Nullがありえる * @param loginedUser */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void connectKnowledge(Long fileNo, Long knowledgeId, Long commentNo, LoginedUser loginedUser) { StringBuilder sql = new StringBuilder(); sql.append("UPDATE KNOWLEDGE_FILES "); sql.append("SET KNOWLEDGE_ID = ?, UPDATE_USER = ?, UPDATE_DATETIME = ?, COMMENT_NO = ? "); sql.append("WHERE FILE_NO = ? "); - executeUpdate(sql.toString(), knowledgeId, loginedUser.getUserId(), new Timestamp(new Date().getTime()), commentNo, fileNo); + executeUpdate(sql.toString(), knowledgeId, loginedUser.getUserId(), new Timestamp(DateUtils.now().getTime()), commentNo, fileNo); } /** @@ -95,7 +100,7 @@ public void connectKnowledge(Long fileNo, Long knowledgeId, Long commentNo, Logi public List deleteNotConnectFiles() { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO FROM KNOWLEDGE_FILES WHERE KNOWLEDGE_ID IS NULL AND DRAFT_ID IS NULL AND UPDATE_DATETIME < ? "); - Timestamp timestamp = new Timestamp(new Date().getTime() - (1000 * 60 * 60 * 24)); + Timestamp timestamp = new Timestamp(DateUtils.now().getTime() - (1000 * 60 * 60 * 24)); return executeQueryList(sql.toString(), KnowledgeFilesEntity.class, timestamp); } @@ -104,6 +109,7 @@ public List deleteNotConnectFiles() { * * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectWaitStateFiles() { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, FILE_NAME, DRAFT_ID, FILE_SIZE, INSERT_USER, "); @@ -125,7 +131,7 @@ public void changeStatus(Long fileNo, int parseStatus, Integer updateUserId) { sql.append("UPDATE KNOWLEDGE_FILES "); sql.append("SET PARSE_STATUS = ?, UPDATE_USER = ?, UPDATE_DATETIME = ? "); sql.append("WHERE FILE_NO = ? "); - executeUpdate(sql.toString(), parseStatus, updateUserId, new Timestamp(new Date().getTime()), fileNo); + executeUpdate(sql.toString(), parseStatus, updateUserId, new Timestamp(DateUtils.now().getTime()), fileNo); } /** @@ -133,13 +139,14 @@ public void changeStatus(Long fileNo, int parseStatus, Integer updateUserId) { * @param entity ファイルEntity * @param updateUserId 更新者 */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void updateDraftId(KnowledgeFilesEntity entity, Integer updateUserId) { StringBuilder sql = new StringBuilder(); sql.append("UPDATE KNOWLEDGE_FILES "); sql.append("SET DRAFT_ID = ?, KNOWLEDGE_ID = ?, UPDATE_USER = ?, UPDATE_DATETIME = ? "); sql.append("WHERE FILE_NO = ? "); executeUpdate(sql.toString(), entity.getDraftId(), entity.getKnowledgeId(), - updateUserId, new Timestamp(new Date().getTime()), entity.getFileNo()); + updateUserId, new Timestamp(DateUtils.now().getTime()), entity.getFileNo()); } diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java index 55baba386..29175aee5 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -33,17 +34,20 @@ public static KnowledgeHistoriesDao get() { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int selectMaxHistoryNo(Long knowledgeId) { String sql = "SELECT MAX(HISTORY_NO) FROM KNOWLEDGE_HISTORIES WHERE KNOWLEDGE_ID = ? "; return executeQuerySingle(sql, Integer.class, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledge(Long knowledgeId, int offset, int limit) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_selectOnKnowledge.sql"); return executeQueryList(sql, KnowledgeHistoriesEntity.class, knowledgeId, limit, offset); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeHistoriesEntity selectOnKeyWithName(Integer historyNo, Long knowledgeId) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_selectOnKeyWithName.sql"); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeItemValuesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeItemValuesDao.java index f5be69599..06c05fb3c 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeItemValuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeItemValuesDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -26,6 +27,7 @@ public static KnowledgeItemValuesDao get() { return Container.getComp(KnowledgeItemValuesDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTypeIdAndItemNoAndStatus(int typeId, int itemNo, int status) { String sql = "SELECT * FROM KNOWLEDGE_ITEM_VALUES WHERE TYPE_ID = ? AND ITEM_NO = ? AND ITEM_STATUS = ? AND DELETE_FLAG = 0"; return executeQueryList(sql, KnowledgeItemValuesEntity.class, typeId, itemNo, status); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeTagsDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeTagsDao.java index 5d64baf8b..0cecb934b 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeTagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeTagsDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -28,6 +29,7 @@ public static KnowledgeTagsDao get() { * * @param knowledgeId */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM KNOWLEDGE_TAGS WHERE KNOWLEDGE_ID = ?"; super.executeUpdate(sql, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeUsersDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeUsersDao.java index 8ae763951..8aaf89d3a 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeUsersDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -28,6 +29,7 @@ public static KnowledgeUsersDao get() { * * @param knowledgeId */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM KNOWLEDGE_USERS WHERE KNOWLEDGE_ID = ?"; super.executeUpdate(sql, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java index a303f82df..183bf27f5 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java @@ -5,6 +5,8 @@ import java.util.Date; import java.util.List; +import org.support.project.aop.Aspect; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -40,6 +42,7 @@ public static KnowledgesDao get() { /** * IDを採番 ※コミットしなくても次のIDを採番する為、保存しなければ欠番になる */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(KNOWLEDGE_ID) FROM KNOWLEDGES;"; Integer integer = executeQuerySingle(sql, Integer.class); @@ -50,6 +53,7 @@ public Integer getNextId() { return currentId; } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectKnowledge(int offset, int limit, Integer userId) { // String sql = "SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 ORDER BY UPDATE_DATETIME DESC Limit ? offset ?;"; String sql = SQLManager.getInstance() @@ -63,6 +67,7 @@ public List selectKnowledge(int offset, int limit, Integer use * @param knowledgeIds * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectKnowledges(List knowledgeIds) { if (knowledgeIds == null || knowledgeIds.isEmpty()) { return new ArrayList(); @@ -97,6 +102,7 @@ public List selectKnowledges(List knowledgeIds) { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgesEntity selectOnKeyWithUserName(Long knowledgeId) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectOnKeyWithUserName.sql"); @@ -109,6 +115,7 @@ public KnowledgesEntity selectOnKeyWithUserName(Long knowledgeId) { * @param userId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnUser(Integer userId) { String sql = "SELECT KNOWLEDGE_ID FROM KNOWLEDGES WHERE INSERT_USER = ? ORDER BY KNOWLEDGE_ID DESC"; return executeQueryList(sql, Long.class, userId); @@ -119,9 +126,10 @@ public List selectOnUser(Integer userId) { * * @param loginUserId */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnUser(Integer loginUserId) { String sql = "UPDATE KNOWLEDGES SET DELETE_FLAG = 1 , UPDATE_USER = ? , UPDATE_DATETIME = ? WHERE INSERT_USER = ?"; - super.executeUpdate(sql, loginUserId, new Timestamp(new Date().getTime()), loginUserId); + super.executeUpdate(sql, loginUserId, new Timestamp(DateUtils.now().getTime()), loginUserId); } /** @@ -131,6 +139,7 @@ public void deleteOnUser(Integer loginUserId) { * @param end * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectBetween(Long start, Long end) { String sql = "SELECT * FROM knowledges WHERE knowledge_id BETWEEN ? AND ? AND DELETE_FLAG = 0 ORDER BY knowledge_id"; return executeQueryList(sql, KnowledgesEntity.class, start, end); @@ -145,6 +154,7 @@ public List selectBetween(Long start, Long end) { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectPopularity(Timestamp start, Timestamp end, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularity.sql"); return executeQueryList(sql, KnowledgesEntity.class, start, end, limit, offset); @@ -160,6 +170,7 @@ public List selectPopularity(Timestamp start, Timestamp end, i * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectPopularityWithAccessControl(LoginedUser loginedUser, Timestamp start, Timestamp end, int offset, int limit) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularityWithAccessControl.sql"); @@ -198,6 +209,7 @@ public List selectPopularityWithAccessControl(LoginedUser logi return executeQueryList(sql, KnowledgesEntity.class, params.toArray(new Object[0])); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectStocks(LoginedUser loginedUser, int offset, int limit, Long stockid) { if (loginedUser == null) { // ログインしていないのであれば、ストックは無し @@ -263,6 +275,7 @@ public List selectStocks(LoginedUser loginedUser, int offset, * @param q * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectKnowledgeOnIdPrefix(String q, int limit, int offset) { String sql = "SELECT KNOWLEDGE_ID, TITLE FROM KNOWLEDGES " + "WHERE CAST(KNOWLEDGE_ID AS VARCHAR(20)) LIKE ? || '%' ORDER BY KNOWLEDGES.KNOWLEDGE_ID DESC LIMIT ? OFFSET ?;"; @@ -274,6 +287,7 @@ public List selectKnowledgeOnIdPrefix(String q, int limit, int * @param q * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAccessAbleKnowledgeOnIdPrefix(String q, LoginedUser loginedUser, int limit, int offset) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectAccessAbleKnowledgeOnIdPrefix.sql"); @@ -311,4 +325,20 @@ public List selectAccessAbleKnowledgeOnIdPrefix(String q, Logi return executeQueryList(sql, KnowledgesEntity.class, params.toArray(new Object[0])); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void updateViewCount(Long count, Long knowledgeId) { + String sql = "UPDATE KNOWLEDGES SET VIEW_COUNT = ? WHERE KNOWLEDGE_ID = ?"; + executeUpdate(sql, count, knowledgeId); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int selectPoint(long knowledgeId) { + String sql = "SELECT POINT FROM KNOWLEDGES WHERE KNOWLEDGE_ID = ?"; + return executeQuerySingle(sql, Integer.class, knowledgeId); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void updatePoint(long knowledgeId, int point) { + String sql = "UPDATE KNOWLEDGES SET POINT = ? WHERE KNOWLEDGE_ID = ?"; + executeUpdate(sql, point, knowledgeId); + } + } diff --git a/src/main/java/org/support/project/knowledge/dao/LikeCommentsDao.java b/src/main/java/org/support/project/knowledge/dao/LikeCommentsDao.java new file mode 100644 index 000000000..30c4c61f3 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/LikeCommentsDao.java @@ -0,0 +1,56 @@ +package org.support.project.knowledge.dao; + +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.gen.GenLikeCommentsDao; +import org.support.project.knowledge.entity.LikeCommentsEntity; +import org.support.project.ormapping.common.SQLManager; + +/** + * コメントのイイネ + */ +@DI(instance = Instance.Singleton) +public class LikeCommentsDao extends GenLikeCommentsDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static LikeCommentsDao get() { + return Container.getComp(LikeCommentsDao.class); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Long selectOnCommentNo(Long commentNo) { + String sql = "SELECT COUNT(*) FROM LIKE_COMMENTS WHERE COMMENT_NO = ?"; + return super.executeQuerySingle(sql, Long.class, commentNo); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnCommentNo(Long commentNo, int offset, int limit) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_selectOnCommentNo.sql"); + return executeQueryList(sql, LikeCommentsEntity.class, commentNo, limit, offset); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity selectExistsOnUser(Long commentNo, Integer userId) { + String sql = "SELECT * FROM LIKE_COMMENTS WHERE COMMENT_NO = ? AND INSERT_USER = ? LIMIT 1 OFFSET 0"; + return super.executeQuerySingle(sql, LikeCommentsEntity.class, commentNo, userId); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectUniqueUserCountOnCommentNo(Long commentNo) { + String sql = "SELECT COUNT(*) FROM (" + + "SELECT COMMENT_NO, INSERT_USER FROM LIKE_COMMENTS WHERE COMMENT_NO = ? GROUP BY COMMENT_NO, INSERT_USER) AS SUBQ"; + return super.executeQuerySingle(sql, Long.class, commentNo); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/LikesDao.java b/src/main/java/org/support/project/knowledge/dao/LikesDao.java index 1bb8ad8e9..55accd9be 100644 --- a/src/main/java/org/support/project/knowledge/dao/LikesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/LikesDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -27,14 +28,31 @@ public static LikesDao get() { return Container.getComp(LikesDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Long countOnKnowledgeId(Long knowledgeId) { String sql = "SELECT COUNT(*) FROM LIKES WHERE KNOWLEDGE_ID = ?"; return super.executeQuerySingle(sql, Long.class, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectUniqueUserCountOnKnowledgeId(Long knowledgeId) { + String sql = "SELECT COUNT(*) FROM (" + + "SELECT KNOWLEDGE_ID, INSERT_USER FROM LIKES WHERE KNOWLEDGE_ID = ? GROUP BY KNOWLEDGE_ID, INSERT_USER) AS SUBQ"; + return super.executeQuerySingle(sql, Long.class, knowledgeId); + } + + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledge(Long knowledgeId, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_selectOnKnowledge.sql"); return executeQueryList(sql, LikesEntity.class, knowledgeId, limit, offset); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikesEntity selectExistsOnUser(Long knowledgeId, Integer userId) { + String sql = "SELECT * FROM LIKES WHERE KNOWLEDGE_ID = ? AND INSERT_USER = ? LIMIT 1 OFFSET 0"; + return super.executeQuerySingle(sql, LikesEntity.class, knowledgeId, userId); + } + + } diff --git a/src/main/java/org/support/project/knowledge/dao/MailHookConditionsDao.java b/src/main/java/org/support/project/knowledge/dao/MailHookConditionsDao.java index 426bc5147..6d3068de2 100644 --- a/src/main/java/org/support/project/knowledge/dao/MailHookConditionsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/MailHookConditionsDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -29,6 +30,7 @@ public static MailHookConditionsDao get() { * @param hookId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int nextConditionNo(Integer hookId) { String sql = "SELECT COUNT(*) FROM MAIL_HOOK_CONDITIONS WHERE HOOK_ID = ?"; int num = super.executeQuerySingle(sql, Integer.class, hookId); diff --git a/src/main/java/org/support/project/knowledge/dao/MailHookIgnoreConditionsDao.java b/src/main/java/org/support/project/knowledge/dao/MailHookIgnoreConditionsDao.java new file mode 100644 index 000000000..19462ea80 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/MailHookIgnoreConditionsDao.java @@ -0,0 +1,27 @@ +package org.support.project.knowledge.dao; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import org.support.project.knowledge.dao.gen.GenMailHookIgnoreConditionsDao; + +/** + * メールから投稿の際の除外条件 + */ +@DI(instance = Instance.Singleton) +public class MailHookIgnoreConditionsDao extends GenMailHookIgnoreConditionsDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static MailHookIgnoreConditionsDao get() { + return Container.getComp(MailHookIgnoreConditionsDao.class); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/MailHooksDao.java b/src/main/java/org/support/project/knowledge/dao/MailHooksDao.java index 017a14a03..5d74c9a47 100644 --- a/src/main/java/org/support/project/knowledge/dao/MailHooksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/MailHooksDao.java @@ -2,7 +2,9 @@ import java.sql.Timestamp; +import org.support.project.aop.Aspect; import org.support.project.common.config.INT_FLAG; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -36,6 +38,7 @@ public static MailHooksDao get() { * Get Next id * @return next id */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(HOOK_ID) FROM MAIL_HOOKS;"; Integer integer = executeQuerySingle(sql, Integer.class); @@ -52,6 +55,7 @@ public Integer getNextId() { * @see org.support.project.knowledge.dao.gen.GenMailHooksDao#save(org.support.project.knowledge.entity.MailHooksEntity) */ @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHooksEntity save(MailHooksEntity entity) { if (entity.getHookId() != null) { MailHooksEntity db = physicalSelectOnKey(entity.getHookId()); @@ -60,7 +64,7 @@ public MailHooksEntity save(MailHooksEntity entity) { } entity.setDeleteFlag(INT_FLAG.OFF.getValue()); entity.setInsertUser((Integer) DBUserPool.get().getUser()); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); return rawPhysicalInsert(entity); } else { return super.save(entity); diff --git a/src/main/java/org/support/project/knowledge/dao/NotificationStatusDao.java b/src/main/java/org/support/project/knowledge/dao/NotificationStatusDao.java new file mode 100644 index 000000000..7614694b8 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/NotificationStatusDao.java @@ -0,0 +1,27 @@ +package org.support.project.knowledge.dao; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import org.support.project.knowledge.dao.gen.GenNotificationStatusDao; + +/** + * いいねの通知状態 + */ +@DI(instance = Instance.Singleton) +public class NotificationStatusDao extends GenNotificationStatusDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static NotificationStatusDao get() { + return Container.getComp(NotificationStatusDao.class); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/NotifyConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/NotifyConfigsDao.java index dbb24cc5b..acf515f1b 100644 --- a/src/main/java/org/support/project/knowledge/dao/NotifyConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/NotifyConfigsDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -35,6 +36,7 @@ public static NotifyConfigsDao get() { /** * IDを採番 ※コミットしなくても次のIDを採番する為、保存しなければ欠番になる */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(USER_ID) FROM NOTIFY_CONFIGS;"; Integer integer = executeQuerySingle(sql, Integer.class); @@ -52,6 +54,7 @@ public Integer getNextId() { * @param offset * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List getNotifyDesktopUsersOnPublicComment(int limit, int offset) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/GetNotifyDesktopUsersOnPublicComment.sql"); @@ -65,6 +68,7 @@ public List getNotifyDesktopUsersOnPublicComment(int limit, int off * @param offset * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List getNotifyMailUsersOnPublicComment(int limit, int offset) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/GetNotifyMailUsersOnPublicComment.sql"); return executeQueryList(sql, UsersEntity.class, limit, offset); diff --git a/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java b/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java index 7e36273d5..a358c9e4a 100644 --- a/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java @@ -1,5 +1,8 @@ package org.support.project.knowledge.dao; +import java.util.List; + +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -24,6 +27,17 @@ public static NotifyQueuesDao get() { return Container.getComp(NotifyQueuesDao.class); } + /** + * Select all data that not deleted. + * @return all data + */ + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + String sql = "SELECT * FROM NOTIFY_QUEUES WHERE DELETE_FLAG = 0 ORDER BY INSERT_DATETIME ASC;"; + return executeQueryList(sql, NotifyQueuesEntity.class); + } + /** * 通知キューに、同一の通知種類/IDの情報が無いか検索する * @@ -31,6 +45,7 @@ public static NotifyQueuesDao get() { * @param id * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyQueuesEntity selectOnTypeAndId(Integer type, Long id) { String sql = "SELECT * FROM NOTIFY_QUEUES WHERE TYPE = ? AND ID = ? AND DELETE_FLAG = 0"; return super.executeQuerySingle(sql, NotifyQueuesEntity.class, type, id); diff --git a/src/main/java/org/support/project/knowledge/dao/ParticipantsDao.java b/src/main/java/org/support/project/knowledge/dao/ParticipantsDao.java index 46fd820a2..3dcc571d8 100644 --- a/src/main/java/org/support/project/knowledge/dao/ParticipantsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ParticipantsDao.java @@ -2,12 +2,11 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; - import org.support.project.knowledge.dao.gen.GenParticipantsDao; -import org.support.project.knowledge.vo.GroupUser; import org.support.project.knowledge.vo.Participation; import org.support.project.ormapping.common.SQLManager; @@ -32,11 +31,19 @@ public static ParticipantsDao get() { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectParticipations(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_selectParticipations.sql"); return executeQueryList(sql, Participation.class, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectUniqueUserCountOnKnowledgeId(Long knowledgeId) { + String sql = "SELECT COUNT(*) FROM (" + + "SELECT KNOWLEDGE_ID, USER_ID FROM PARTICIPANTS WHERE KNOWLEDGE_ID = ? GROUP BY KNOWLEDGE_ID, USER_ID) AS SUBQ"; + return super.executeQuerySingle(sql, Long.class, knowledgeId); + } + } diff --git a/src/main/java/org/support/project/knowledge/dao/PinsDao.java b/src/main/java/org/support/project/knowledge/dao/PinsDao.java index 9dc1eeeb4..07ef71e8d 100644 --- a/src/main/java/org/support/project/knowledge/dao/PinsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/PinsDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -31,6 +32,7 @@ public static PinsDao get() { * IDを採番 * ※コミットしなくても次のIDを採番する為、保存しなければ欠番になる */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(no) FROM pins;"; Integer integer = executeQuerySingle(sql, Integer.class); diff --git a/src/main/java/org/support/project/knowledge/dao/PointKnowledgeHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/PointKnowledgeHistoriesDao.java new file mode 100644 index 000000000..4dc9a9b6c --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/PointKnowledgeHistoriesDao.java @@ -0,0 +1,70 @@ +package org.support.project.knowledge.dao; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.gen.GenPointKnowledgeHistoriesDao; + +/** + * ナレッジのポイント獲得履歴 + */ +@DI(instance = Instance.Singleton) +public class PointKnowledgeHistoriesDao extends GenPointKnowledgeHistoriesDao { + /** LOG */ + private static final Log LOG = LogFactory.getLog(PointKnowledgeHistoriesDao.class); + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static PointKnowledgeHistoriesDao get() { + return Container.getComp(PointKnowledgeHistoriesDao.class); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectNumOnKnowledge(long knowledgeId) { + String sql = "SELECT MAX(HISTORY_NO) FROM POINT_KNOWLEDGE_HISTORIES WHERE KNOWLEDGE_ID = ?"; + return executeQuerySingle(sql, Long.class, knowledgeId); + } + public int selectBeforePoint(Long knowledgeId, int... types) { + StringBuilder sql = new StringBuilder(); + List params = new ArrayList<>(); + sql.append("SELECT SUM(POINT) FROM POINT_KNOWLEDGE_HISTORIES "); + sql.append("WHERE KNOWLEDGE_ID = ? "); + params.add(knowledgeId); + sql.append("AND TYPE IN ("); + boolean appended = false; + for (int i : types) { + if (appended) { + sql.append(", "); + + } + sql.append("?"); + appended = true; + params.add(i); + } + sql.append(");"); + Integer point = executeQuerySingle(sql.toString(), Integer.class, params.toArray(new Object[0])); + if (point == null) { + point = 0; + } + return point; + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void removeAll() { + LOG.warn("Remove all point knowledge histories"); + String sql = "DELETE FROM POINT_KNOWLEDGE_HISTORIES"; + executeUpdate(sql); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/PointUserHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/PointUserHistoriesDao.java new file mode 100644 index 000000000..2c7ca08b2 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/PointUserHistoriesDao.java @@ -0,0 +1,96 @@ +package org.support.project.knowledge.dao; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.gen.GenPointUserHistoriesDao; +import org.support.project.knowledge.entity.PointUserHistoriesEntity; +import org.support.project.knowledge.vo.ContributionPointHistory; +import org.support.project.knowledge.vo.UserConfigs; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; + +/** + * ユーザのポイント獲得履歴 + */ +@DI(instance = Instance.Singleton) +public class PointUserHistoriesDao extends GenPointUserHistoriesDao { + /** ログ */ + private static final Log LOG = LogFactory.getLog(PointUserHistoriesDao.class); + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static PointUserHistoriesDao get() { + return Container.getComp(PointUserHistoriesDao.class); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectNumOnUser(int user) { + String sql = "SELECT MAX(HISTORY_NO) FROM POINT_USER_HISTORIES WHERE USER_ID = ?"; + return executeQuerySingle(sql, Long.class, user); + } + + private String convTimeToString(int min) throws ParseException { + boolean minus = false; + if (min < 0) { + minus = true; + min = min * -1; + } + SimpleDateFormat time = new SimpleDateFormat("HH:mm"); + SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date d = format.parse("2000/01/01 00:00:00"); + d.setTime(d.getTime() + (min * 60 * 1000)); + StringBuilder builder = new StringBuilder(); + if (minus) { + builder.append("-"); + } + builder.append(time.format(d)); + return builder.toString(); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectPointHistoriesByDate(Integer userId, UserConfigs userConfigs) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date.sql"); + if (ConnectionManager.getInstance().getDriverClass().indexOf("postgresql") != -1) { + String min; + try { + min = convTimeToString(userConfigs.getTimezoneOffset()); + } catch (ParseException e) { + min = "00:00"; + } + return executeQueryList(sql, ContributionPointHistory.class, min, userId); + } else { + return executeQueryList(sql, ContributionPointHistory.class, userConfigs.getTimezoneOffset(), userId); + } + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnUser(Integer userId, int limit, int offset, Order order) { + String sql = "SELECT * FROM POINT_USER_HISTORIES WHERE USER_ID = ? ORDER BY INSERT_DATETIME %S LIMIT ? OFFSET ?;"; + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointUserHistoriesEntity.class, userId, limit, offset); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void removeAll() { + LOG.warn("Remove all point user histories"); + String sql = "DELETE FROM POINT_USER_HISTORIES"; + executeUpdate(sql); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/StockKnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/StockKnowledgesDao.java index 186d668e1..e9273d535 100644 --- a/src/main/java/org/support/project/knowledge/dao/StockKnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/StockKnowledgesDao.java @@ -3,6 +3,8 @@ import java.util.Date; import java.util.List; +import org.support.project.aop.Aspect; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -37,6 +39,7 @@ public static StockKnowledgesDao get() { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnStockIdWithKnowledgeInfo(Long stockId, int offset, int limit) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_selectOnStockIdWithKnowledgeInfo.sql"); @@ -47,6 +50,7 @@ public List selectOnStockIdWithKnowledgeInfo(Long stockId * @param stockId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectActiveOnStockId(Long stockId) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_active_on_stock_id.sql"); @@ -57,10 +61,11 @@ public List selectActiveOnStockId(Long stockId) { * 指定のナレッジが削除されたときに、ストックからも消す * @param knowledgeId */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { DBUserPool pool = Container.getComp(DBUserPool.class); Integer user = (Integer) pool.getUser(); - Date now = new Date(); + Date now = DateUtils.now(); String sql = "UPDATE stock_knowledges SET delete_flag = 1, update_user = ?, update_datetime = ? WHERE knowledge_id = ?"; executeUpdate(sql, user, now, knowledgeId); } diff --git a/src/main/java/org/support/project/knowledge/dao/StocksDao.java b/src/main/java/org/support/project/knowledge/dao/StocksDao.java index ef78e67ef..950214495 100644 --- a/src/main/java/org/support/project/knowledge/dao/StocksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/StocksDao.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -39,6 +40,7 @@ public static StocksDao get() { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectMyStocksWithKnowledgeCount(LoginedUser loginedUser, int offset, int limit) { String sql = SQLManager.getInstance() .getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_selectMyStocksWithKnowledgeCount.sql"); @@ -54,6 +56,7 @@ public List selectMyStocksWithKnowledgeCount(LoginedUser loginedUs * @param listLimit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectMyStocksWithStocked(LoginedUser loginedUser, Long knowledgeId, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_selectMyStocksWithStocked.sql"); return executeQueryList(sql, Stock.class, knowledgeId, loginedUser.getUserId(), limit, offset); @@ -65,6 +68,7 @@ public List selectMyStocksWithStocked(LoginedUser loginedUser, Long knowl * @param loginedUser * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectStockOnKnowledge(KnowledgesEntity knowledgesEntity, LoginedUser loginedUser) { if (knowledgesEntity == null || loginedUser == null) { return new ArrayList<>(); @@ -80,6 +84,7 @@ public List selectStockOnKnowledge(KnowledgesEntity knowledgesEnti * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectMyStocks(LoginedUser loginedUser, int offset, int limit) { String sql = "SELECT * FROM STOCKS WHERE STOCKS.INSERT_USER = ? AND STOCKS.DELETE_FLAG = 0 ORDER BY STOCKS.INSERT_DATETIME LIMIT ? OFFSET ?"; return executeQueryList(sql, StocksEntity.class, loginedUser.getUserId(), limit, offset); diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java index 3cb0d0fc2..4f516c61b 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -21,10 +22,12 @@ public class SurveyAnswersDao extends GenSurveyAnswersDao { public static SurveyAnswersDao get() { return Container.getComp(SurveyAnswersDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM SURVEY_ANSWERS WHERE KNOWLEDGE_ID = ?"; executeUpdate(sql, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int selectCountOnKnowledgeId(Long knowledgeId) { String sql = "SELECT COUNT(*) FROM SURVEY_ANSWERS WHERE KNOWLEDGE_ID = ?"; return executeQuerySingle(sql, Integer.class, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java index 3d9351875..64518df12 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -22,6 +23,7 @@ public static SurveyChoicesDao get() { return Container.getComp(SurveyChoicesDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM SURVEY_CHOICES WHERE KNOWLEDGE_ID = ?"; executeUpdate(sql, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java index ebb910684..a8f60761f 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -24,10 +25,12 @@ public class SurveyItemAnswersDao extends GenSurveyItemAnswersDao { public static SurveyItemAnswersDao get() { return Container.getComp(SurveyItemAnswersDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM SURVEY_ITEM_ANSWERS WHERE KNOWLEDGE_ID = ?"; executeUpdate(sql, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeIdAndAnswerId(Long knowledgeId, Integer userId) { String sql = "SELECT * FROM SURVEY_ITEM_ANSWERS WHERE KNOWLEDGE_ID = ? AND ANSWER_ID = ?"; return executeQueryList(sql, SurveyItemAnswersEntity.class, knowledgeId, userId); diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java index cda8433c6..8d28c54d9 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -21,6 +22,7 @@ public static SurveyItemsDao get() { return Container.getComp(SurveyItemsDao.class); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void deleteOnKnowledgeId(Long knowledgeId) { String sql = "DELETE FROM SURVEY_ITEMS WHERE KNOWLEDGE_ID = ?"; executeUpdate(sql, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/SurveysDao.java b/src/main/java/org/support/project/knowledge/dao/SurveysDao.java index bc3aa36de..e0b369421 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveysDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveysDao.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -35,6 +36,7 @@ public static SurveysDao get() { * @param offset * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectWithKnowledgeTitle(String idPrefix, int limit, int offset) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_with_knowledge_title.sql"); return executeQueryList(sql, SurveysEntity.class, idPrefix, limit, offset); @@ -49,6 +51,7 @@ public List selectWithKnowledgeTitle(String idPrefix, int limit, * @param offset * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectWithKnowledgeTitleOnlyAccessAble(LoginedUser loginedUser, String idPrefix, int limit, int offset) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_accessable.sql"); List params = new ArrayList<>(); diff --git a/src/main/java/org/support/project/knowledge/dao/TagsDao.java b/src/main/java/org/support/project/knowledge/dao/TagsDao.java index 03a42ee5a..706f03a5d 100644 --- a/src/main/java/org/support/project/knowledge/dao/TagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TagsDao.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.common.util.StringJoinBuilder; import org.support.project.di.Container; import org.support.project.di.DI; @@ -38,6 +39,7 @@ public static TagsDao get() { /** * IDを採番 ※コミットしなくても次のIDを採番する為、保存しなければ欠番になる */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(TAG_ID) FROM TAGS;"; Integer integer = executeQuerySingle(sql, Integer.class); @@ -54,6 +56,7 @@ public Integer getNextId() { * @param tag * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TagsEntity selectOnTagName(String tag) { String sql = "SELECT * FROM TAGS WHERE TAG_NAME = ?"; return executeQuerySingle(sql, TagsEntity.class, tag); @@ -65,6 +68,7 @@ public TagsEntity selectOnTagName(String tag) { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectOnKnowledgeId.sql"); return executeQueryList(sql, TagsEntity.class, knowledgeId); @@ -77,6 +81,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectTagsWithCount(int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCount.sql"); return executeQueryList(sql, TagsEntity.class, limit, offset); @@ -91,6 +96,7 @@ public List selectTagsWithCount(int offset, int limit) { * @return * @deprecated */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectTagsWithCountOnUser(int userid, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCountOnUser.sql"); return executeQueryList(sql, TagsEntity.class, userid, limit, offset); @@ -104,6 +110,7 @@ public List selectTagsWithCountOnUser(int userid, int offset, int li * @param loginedUser * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectWithKnowledgeCount(int userId, List groups, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql"); StringJoinBuilder builder = new StringJoinBuilder(); @@ -130,6 +137,7 @@ public List selectWithKnowledgeCount(int userId, List * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectWithKnowledgeCountAdmin(int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql"); return executeQueryList(sql, TagsEntity.class, limit, offset); @@ -142,6 +150,7 @@ public List selectWithKnowledgeCountAdmin(int offset, int limit) { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectWithKnowledgeCountOnTagName(String keyword, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountOnTagName.sql"); StringBuilder builder = new StringBuilder(); diff --git a/src/main/java/org/support/project/knowledge/dao/TargetsDao.java b/src/main/java/org/support/project/knowledge/dao/TargetsDao.java index e10230fdc..e80be9665 100644 --- a/src/main/java/org/support/project/knowledge/dao/TargetsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TargetsDao.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.common.util.StringJoinBuilder; import org.support.project.di.Container; import org.support.project.ormapping.common.SQLManager; @@ -32,6 +33,7 @@ public static TargetsDao get() { * @param limit * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKeyword(String keyword, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectOnKeyword.sql"); return executeQueryList(sql, LabelValue.class, keyword, keyword, limit, offset); @@ -43,6 +45,7 @@ public List selectOnKeyword(String keyword, int offset, int limit) { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectGroupsOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectGroupsOnKnowledgeId.sql"); return executeQueryList(sql, GroupsEntity.class, knowledgeId); @@ -54,6 +57,7 @@ public List selectGroupsOnKnowledgeId(Long knowledgeId) { * @param knowledgeIds * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectGroupsOnKnowledgeIds(List knowledgeIds) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectGroupsOnKnowledgeIds.sql"); @@ -75,6 +79,7 @@ public List selectGroupsOnKnowledgeIds(List knowledgeIds) { * @param knowledgeId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectUsersOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectUsersOnKnowledgeId.sql"); return executeQueryList(sql, UsersEntity.class, knowledgeId); @@ -86,6 +91,7 @@ public List selectUsersOnKnowledgeId(Long knowledgeId) { * @param knowledgeIds * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectUsersOnKnowledgeIds(List knowledgeIds) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectUsersOnKnowledgeIds.sql"); @@ -101,11 +107,13 @@ public List selectUsersOnKnowledgeIds(List knowledgeIds) { return executeQueryList(sql, UsersEntity.class, params.toArray(new Long[0])); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectEditorGroupsOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectEditorGroupsOnKnowledgeId.sql"); return executeQueryList(sql, GroupsEntity.class, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectEditorUsersOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectEditorUsersOnKnowledgeId.sql"); return executeQueryList(sql, UsersEntity.class, knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java b/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java index b417e7822..bc86dfd32 100644 --- a/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java @@ -37,6 +37,7 @@ public static TemplateMastersDao get() { /** * IDを採番 ※コミットしなくても次のIDを採番する為、保存しなければ欠番になる */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(TYPE_ID) FROM TEMPLATE_MASTERS;"; Integer integer = executeQuerySingle(sql, Integer.class); @@ -52,6 +53,7 @@ public Integer getNextId() { * * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateMastersEntity selectWithItems(Integer typeId) { TemplateMastersEntity template = selectOnKey(typeId); List items = TemplateItemsDao.get().selectOnTypeId(typeId); @@ -93,6 +95,7 @@ public void resetSequence() { * @param template * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateMastersEntity selectOnName(String template) { String sql = "SELECT * FROM TEMPLATE_MASTERS WHERE TYPE_NAME = ? AND DELETE_FLAG = 0"; return executeQuerySingle(sql, TemplateMastersEntity.class, template); diff --git a/src/main/java/org/support/project/knowledge/dao/TokensDao.java b/src/main/java/org/support/project/knowledge/dao/TokensDao.java index 02fed72dc..a1e7b781c 100644 --- a/src/main/java/org/support/project/knowledge/dao/TokensDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TokensDao.java @@ -1,5 +1,6 @@ package org.support.project.knowledge.dao; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -28,6 +29,7 @@ public static TokensDao get() { * @param userId * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TokensEntity selectOnUserId(Integer userId) { String sql = "SELECT * FROM TOKENS WHERE USER_ID = ? AND DELETE_FLAG = 0"; return executeQuerySingle(sql, TokensEntity.class, userId); diff --git a/src/main/java/org/support/project/knowledge/dao/UserBadgesDao.java b/src/main/java/org/support/project/knowledge/dao/UserBadgesDao.java new file mode 100644 index 000000000..4ce1a6862 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/UserBadgesDao.java @@ -0,0 +1,27 @@ +package org.support.project.knowledge.dao; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import org.support.project.knowledge.dao.gen.GenUserBadgesDao; + +/** + * ユーザの称号 + */ +@DI(instance = Instance.Singleton) +public class UserBadgesDao extends GenUserBadgesDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static UserBadgesDao get() { + return Container.getComp(UserBadgesDao.class); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/ViewHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/ViewHistoriesDao.java index 188cb3f4a..4e8cbe0a7 100644 --- a/src/main/java/org/support/project/knowledge/dao/ViewHistoriesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ViewHistoriesDao.java @@ -1,9 +1,15 @@ package org.support.project.knowledge.dao; +import java.util.ArrayList; +import java.util.List; + +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.dao.gen.GenViewHistoriesDao; +import org.support.project.knowledge.entity.ViewHistoriesEntity; +import org.support.project.knowledge.vo.StockKnowledge; /** * ナレッジの参照履歴 @@ -22,5 +28,56 @@ public class ViewHistoriesDao extends GenViewHistoriesDao { public static ViewHistoriesDao get() { return Container.getComp(ViewHistoriesDao.class); } + + /** + * 指定のKnowledgeを参照したことがあるか検索して取得 + * @param stocks + * @param userId + * @return + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectViewdKnowledgeIds(List stocks, Integer userId) { + if (stocks == null || stocks.isEmpty()) { + return new ArrayList<>(); + } + StringBuilder sql = new StringBuilder(); + sql.append("SELECT DISTINCT KNOWLEDGE_ID FROM VIEW_HISTORIES WHERE KNOWLEDGE_ID IN ("); + int cnt = 0; + List params = new ArrayList<>(); + for (StockKnowledge knowledge : stocks) { + if (cnt > 0) { + sql.append(", "); + } + params.add(knowledge.getKnowledgeId()); + sql.append("?"); + cnt++; + } + sql.append(") AND INSERT_USER = ?"); + params.add(userId); + return executeQueryList(sql.toString(), Long.class, params.toArray(new Object[0])); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectCountOnKnowledgeId(Long knowledgeId) { + String sql = "SELECT COUNT(*) FROM VIEW_HISTORIES WHERE KNOWLEDGE_ID = ?"; + return executeQuerySingle(sql, Long.class, knowledgeId); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public long selectUniqueUserCountOnKnowledgeId(Long knowledgeId) { + String sql = "SELECT COUNT(*) FROM (" + + "SELECT KNOWLEDGE_ID, INSERT_USER FROM VIEW_HISTORIES WHERE KNOWLEDGE_ID = ? GROUP BY KNOWLEDGE_ID, INSERT_USER) AS SUBQ"; + return executeQuerySingle(sql, Long.class, knowledgeId); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectDistinctAllWidthPager(int limit, int offset) { + String sql = "SELECT * FROM VIEW_HISTORIES AS M WHERE NOT EXISTS (" + + "SELECT 1 FROM VIEW_HISTORIES AS S WHERE M.KNOWLEDGE_ID = S.KNOWLEDGE_ID " + + "AND M.INSERT_USER = S.INSERT_USER " + + "AND M.INSERT_DATETIME > S.INSERT_DATETIME" + + ") AND M.INSERT_USER IS NOT NULL " + + "ORDER BY M.KNOWLEDGE_ID ASC LIMIT ? OFFSET ?;"; + return executeQueryList(sql.toString(), ViewHistoriesEntity.class, limit, offset); + } } diff --git a/src/main/java/org/support/project/knowledge/dao/WebhookConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/WebhookConfigsDao.java index 5821fde95..40508082c 100644 --- a/src/main/java/org/support/project/knowledge/dao/WebhookConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/WebhookConfigsDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -34,6 +35,7 @@ public static WebhookConfigsDao get() { /** * IDを採番 ※コミットしなくても次のIDを採番する為、保存しなければ欠番になる */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer getNextId() { String sql = "SELECT MAX(HOOK_ID) FROM WEBHOOK_CONFIGS;"; Integer integer = executeQuerySingle(sql, Integer.class); @@ -50,6 +52,7 @@ public Integer getNextId() { * @param hook * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnHook(String hook) { String sql = "SELECT * FROM WEBHOOK_CONFIGS WHERE HOOK = ? AND DELETE_FLAG = 0"; return executeQueryList(sql, WebhookConfigsEntity.class, hook); diff --git a/src/main/java/org/support/project/knowledge/dao/WebhooksDao.java b/src/main/java/org/support/project/knowledge/dao/WebhooksDao.java index 1676196fb..2780c729a 100644 --- a/src/main/java/org/support/project/knowledge/dao/WebhooksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/WebhooksDao.java @@ -2,6 +2,7 @@ import java.util.List; +import org.support.project.aop.Aspect; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -32,6 +33,7 @@ public static WebhooksDao get() { * @param status * @return */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnStatus(int status) { String sql = "SELECT * FROM WEBHOOKS WHERE STATUS = ? AND DELETE_FLAG = 0"; return executeQueryList(sql, WebhooksEntity.class, status); diff --git a/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java b/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java index ec0d490f8..11e643a56 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java @@ -20,50 +20,58 @@ public class DatabaseControlDao extends AbstractDao { /** Drop all tables */ public void dropAllTable() { - String[] sqls = new String[43]; + String[] sqls = new String[51]; sqls[0] = "DROP TABLE IF EXISTS KNOWLEDGES CASCADE;"; - sqls[1] = "DROP TABLE IF EXISTS SERVICE_LOCALE_CONFIGS CASCADE;"; - sqls[2] = "DROP TABLE IF EXISTS ACCOUNT_IMAGES CASCADE;"; - sqls[3] = "DROP TABLE IF EXISTS EVENTS CASCADE;"; - sqls[4] = "DROP TABLE IF EXISTS MAIL_POSTS CASCADE;"; - sqls[5] = "DROP TABLE IF EXISTS MAIL_PROPERTIES CASCADE;"; - sqls[6] = "DROP TABLE IF EXISTS WEBHOOK_CONFIGS CASCADE;"; - sqls[7] = "DROP TABLE IF EXISTS MAIL_LOCALE_TEMPLATES CASCADE;"; - sqls[8] = "DROP TABLE IF EXISTS VOTES CASCADE;"; - sqls[9] = "DROP TABLE IF EXISTS COMMENTS CASCADE;"; - sqls[10] = "DROP TABLE IF EXISTS SURVEY_CHOICES CASCADE;"; - sqls[11] = "DROP TABLE IF EXISTS TOKENS CASCADE;"; - sqls[12] = "DROP TABLE IF EXISTS KNOWLEDGE_GROUPS CASCADE;"; - sqls[13] = "DROP TABLE IF EXISTS MAIL_HOOK_CONDITIONS CASCADE;"; - sqls[14] = "DROP TABLE IF EXISTS SURVEY_ITEM_ANSWERS CASCADE;"; - sqls[15] = "DROP TABLE IF EXISTS LIKES CASCADE;"; - sqls[16] = "DROP TABLE IF EXISTS DRAFT_ITEM_VALUES CASCADE;"; - sqls[17] = "DROP TABLE IF EXISTS VIEW_HISTORIES CASCADE;"; - sqls[18] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_GROUPS CASCADE;"; - sqls[19] = "DROP TABLE IF EXISTS WEBHOOKS CASCADE;"; - sqls[20] = "DROP TABLE IF EXISTS KNOWLEDGE_FILES CASCADE;"; - sqls[21] = "DROP TABLE IF EXISTS NOTIFY_QUEUES CASCADE;"; - sqls[22] = "DROP TABLE IF EXISTS TEMPLATE_MASTERS CASCADE;"; - sqls[23] = "DROP TABLE IF EXISTS SERVICE_CONFIGS CASCADE;"; - sqls[24] = "DROP TABLE IF EXISTS ITEM_CHOICES CASCADE;"; - sqls[25] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_USERS CASCADE;"; - sqls[26] = "DROP TABLE IF EXISTS PINS CASCADE;"; - sqls[27] = "DROP TABLE IF EXISTS KNOWLEDGE_HISTORIES CASCADE;"; - sqls[28] = "DROP TABLE IF EXISTS KNOWLEDGE_ITEM_VALUES CASCADE;"; - sqls[29] = "DROP TABLE IF EXISTS KNOWLEDGE_TAGS CASCADE;"; - sqls[30] = "DROP TABLE IF EXISTS SURVEY_ANSWERS CASCADE;"; - sqls[31] = "DROP TABLE IF EXISTS SURVEYS CASCADE;"; - sqls[32] = "DROP TABLE IF EXISTS MAIL_TEMPLATES CASCADE;"; - sqls[33] = "DROP TABLE IF EXISTS NOTIFY_CONFIGS CASCADE;"; - sqls[34] = "DROP TABLE IF EXISTS SURVEY_ITEMS CASCADE;"; - sqls[35] = "DROP TABLE IF EXISTS MAIL_HOOKS CASCADE;"; - sqls[36] = "DROP TABLE IF EXISTS DRAFT_KNOWLEDGES CASCADE;"; - sqls[37] = "DROP TABLE IF EXISTS STOCKS CASCADE;"; - sqls[38] = "DROP TABLE IF EXISTS STOCK_KNOWLEDGES CASCADE;"; - sqls[39] = "DROP TABLE IF EXISTS KNOWLEDGE_USERS CASCADE;"; - sqls[40] = "DROP TABLE IF EXISTS PARTICIPANTS CASCADE;"; - sqls[41] = "DROP TABLE IF EXISTS TAGS CASCADE;"; - sqls[42] = "DROP TABLE IF EXISTS TEMPLATE_ITEMS CASCADE;"; + sqls[1] = "DROP TABLE IF EXISTS EVENTS CASCADE;"; + sqls[2] = "DROP TABLE IF EXISTS MAIL_POSTS CASCADE;"; + sqls[3] = "DROP TABLE IF EXISTS WEBHOOK_CONFIGS CASCADE;"; + sqls[4] = "DROP TABLE IF EXISTS SURVEY_CHOICES CASCADE;"; + sqls[5] = "DROP TABLE IF EXISTS KNOWLEDGE_GROUPS CASCADE;"; + sqls[6] = "DROP TABLE IF EXISTS SURVEY_ITEM_ANSWERS CASCADE;"; + sqls[7] = "DROP TABLE IF EXISTS DRAFT_ITEM_VALUES CASCADE;"; + sqls[8] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_GROUPS CASCADE;"; + sqls[9] = "DROP TABLE IF EXISTS WEBHOOKS CASCADE;"; + sqls[10] = "DROP TABLE IF EXISTS KNOWLEDGE_FILES CASCADE;"; + sqls[11] = "DROP TABLE IF EXISTS NOTIFY_QUEUES CASCADE;"; + sqls[12] = "DROP TABLE IF EXISTS TEMPLATE_MASTERS CASCADE;"; + sqls[13] = "DROP TABLE IF EXISTS ITEM_CHOICES CASCADE;"; + sqls[14] = "DROP TABLE IF EXISTS KNOWLEDGE_ITEM_VALUES CASCADE;"; + sqls[15] = "DROP TABLE IF EXISTS KNOWLEDGE_TAGS CASCADE;"; + sqls[16] = "DROP TABLE IF EXISTS NOTIFICATION_STATUS CASCADE;"; + sqls[17] = "DROP TABLE IF EXISTS USER_BADGES CASCADE;"; + sqls[18] = "DROP TABLE IF EXISTS NOTIFY_CONFIGS CASCADE;"; + sqls[19] = "DROP TABLE IF EXISTS MAIL_HOOKS CASCADE;"; + sqls[20] = "DROP TABLE IF EXISTS DRAFT_KNOWLEDGES CASCADE;"; + sqls[21] = "DROP TABLE IF EXISTS STOCK_KNOWLEDGES CASCADE;"; + sqls[22] = "DROP TABLE IF EXISTS KNOWLEDGE_USERS CASCADE;"; + sqls[23] = "DROP TABLE IF EXISTS PARTICIPANTS CASCADE;"; + sqls[24] = "DROP TABLE IF EXISTS TAGS CASCADE;"; + sqls[25] = "DROP TABLE IF EXISTS SERVICE_LOCALE_CONFIGS CASCADE;"; + sqls[26] = "DROP TABLE IF EXISTS ACCOUNT_IMAGES CASCADE;"; + sqls[27] = "DROP TABLE IF EXISTS MAIL_PROPERTIES CASCADE;"; + sqls[28] = "DROP TABLE IF EXISTS POINT_KNOWLEDGE_HISTORIES CASCADE;"; + sqls[29] = "DROP TABLE IF EXISTS MAIL_LOCALE_TEMPLATES CASCADE;"; + sqls[30] = "DROP TABLE IF EXISTS VOTES CASCADE;"; + sqls[31] = "DROP TABLE IF EXISTS COMMENTS CASCADE;"; + sqls[32] = "DROP TABLE IF EXISTS TOKENS CASCADE;"; + sqls[33] = "DROP TABLE IF EXISTS MAIL_HOOK_CONDITIONS CASCADE;"; + sqls[34] = "DROP TABLE IF EXISTS LIKES CASCADE;"; + sqls[35] = "DROP TABLE IF EXISTS VIEW_HISTORIES CASCADE;"; + sqls[36] = "DROP TABLE IF EXISTS SERVICE_CONFIGS CASCADE;"; + sqls[37] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_USERS CASCADE;"; + sqls[38] = "DROP TABLE IF EXISTS PINS CASCADE;"; + sqls[39] = "DROP TABLE IF EXISTS KNOWLEDGE_HISTORIES CASCADE;"; + sqls[40] = "DROP TABLE IF EXISTS LIKE_COMMENTS CASCADE;"; + sqls[41] = "DROP TABLE IF EXISTS BADGES CASCADE;"; + sqls[42] = "DROP TABLE IF EXISTS SURVEY_ANSWERS CASCADE;"; + sqls[43] = "DROP TABLE IF EXISTS SURVEYS CASCADE;"; + sqls[44] = "DROP TABLE IF EXISTS ACTIVITIES CASCADE;"; + sqls[45] = "DROP TABLE IF EXISTS MAIL_HOOK_IGNORE_CONDITIONS CASCADE;"; + sqls[46] = "DROP TABLE IF EXISTS MAIL_TEMPLATES CASCADE;"; + sqls[47] = "DROP TABLE IF EXISTS POINT_USER_HISTORIES CASCADE;"; + sqls[48] = "DROP TABLE IF EXISTS SURVEY_ITEMS CASCADE;"; + sqls[49] = "DROP TABLE IF EXISTS STOCKS CASCADE;"; + sqls[50] = "DROP TABLE IF EXISTS TEMPLATE_ITEMS CASCADE;"; for (String sql : sqls) { LOG.debug(sql); executeUpdate(sql); @@ -71,50 +79,58 @@ public void dropAllTable() { } /** Delete all table data */ public void dropAllData() { - String[] sqls = new String[43]; + String[] sqls = new String[51]; sqls[0] = "TRUNCATE TABLE KNOWLEDGES;"; - sqls[1] = "TRUNCATE TABLE SERVICE_LOCALE_CONFIGS;"; - sqls[2] = "TRUNCATE TABLE ACCOUNT_IMAGES;"; - sqls[3] = "TRUNCATE TABLE EVENTS;"; - sqls[4] = "TRUNCATE TABLE MAIL_POSTS;"; - sqls[5] = "TRUNCATE TABLE MAIL_PROPERTIES;"; - sqls[6] = "TRUNCATE TABLE WEBHOOK_CONFIGS;"; - sqls[7] = "TRUNCATE TABLE MAIL_LOCALE_TEMPLATES;"; - sqls[8] = "TRUNCATE TABLE VOTES;"; - sqls[9] = "TRUNCATE TABLE COMMENTS;"; - sqls[10] = "TRUNCATE TABLE SURVEY_CHOICES;"; - sqls[11] = "TRUNCATE TABLE TOKENS;"; - sqls[12] = "TRUNCATE TABLE KNOWLEDGE_GROUPS;"; - sqls[13] = "TRUNCATE TABLE MAIL_HOOK_CONDITIONS;"; - sqls[14] = "TRUNCATE TABLE SURVEY_ITEM_ANSWERS;"; - sqls[15] = "TRUNCATE TABLE LIKES;"; - sqls[16] = "TRUNCATE TABLE DRAFT_ITEM_VALUES;"; - sqls[17] = "TRUNCATE TABLE VIEW_HISTORIES;"; - sqls[18] = "TRUNCATE TABLE KNOWLEDGE_EDIT_GROUPS;"; - sqls[19] = "TRUNCATE TABLE WEBHOOKS;"; - sqls[20] = "TRUNCATE TABLE KNOWLEDGE_FILES;"; - sqls[21] = "TRUNCATE TABLE NOTIFY_QUEUES;"; - sqls[22] = "TRUNCATE TABLE TEMPLATE_MASTERS;"; - sqls[23] = "TRUNCATE TABLE SERVICE_CONFIGS;"; - sqls[24] = "TRUNCATE TABLE ITEM_CHOICES;"; - sqls[25] = "TRUNCATE TABLE KNOWLEDGE_EDIT_USERS;"; - sqls[26] = "TRUNCATE TABLE PINS;"; - sqls[27] = "TRUNCATE TABLE KNOWLEDGE_HISTORIES;"; - sqls[28] = "TRUNCATE TABLE KNOWLEDGE_ITEM_VALUES;"; - sqls[29] = "TRUNCATE TABLE KNOWLEDGE_TAGS;"; - sqls[30] = "TRUNCATE TABLE SURVEY_ANSWERS;"; - sqls[31] = "TRUNCATE TABLE SURVEYS;"; - sqls[32] = "TRUNCATE TABLE MAIL_TEMPLATES;"; - sqls[33] = "TRUNCATE TABLE NOTIFY_CONFIGS;"; - sqls[34] = "TRUNCATE TABLE SURVEY_ITEMS;"; - sqls[35] = "TRUNCATE TABLE MAIL_HOOKS;"; - sqls[36] = "TRUNCATE TABLE DRAFT_KNOWLEDGES;"; - sqls[37] = "TRUNCATE TABLE STOCKS;"; - sqls[38] = "TRUNCATE TABLE STOCK_KNOWLEDGES;"; - sqls[39] = "TRUNCATE TABLE KNOWLEDGE_USERS;"; - sqls[40] = "TRUNCATE TABLE PARTICIPANTS;"; - sqls[41] = "TRUNCATE TABLE TAGS;"; - sqls[42] = "TRUNCATE TABLE TEMPLATE_ITEMS;"; + sqls[1] = "TRUNCATE TABLE EVENTS;"; + sqls[2] = "TRUNCATE TABLE MAIL_POSTS;"; + sqls[3] = "TRUNCATE TABLE WEBHOOK_CONFIGS;"; + sqls[4] = "TRUNCATE TABLE SURVEY_CHOICES;"; + sqls[5] = "TRUNCATE TABLE KNOWLEDGE_GROUPS;"; + sqls[6] = "TRUNCATE TABLE SURVEY_ITEM_ANSWERS;"; + sqls[7] = "TRUNCATE TABLE DRAFT_ITEM_VALUES;"; + sqls[8] = "TRUNCATE TABLE KNOWLEDGE_EDIT_GROUPS;"; + sqls[9] = "TRUNCATE TABLE WEBHOOKS;"; + sqls[10] = "TRUNCATE TABLE KNOWLEDGE_FILES;"; + sqls[11] = "TRUNCATE TABLE NOTIFY_QUEUES;"; + sqls[12] = "TRUNCATE TABLE TEMPLATE_MASTERS;"; + sqls[13] = "TRUNCATE TABLE ITEM_CHOICES;"; + sqls[14] = "TRUNCATE TABLE KNOWLEDGE_ITEM_VALUES;"; + sqls[15] = "TRUNCATE TABLE KNOWLEDGE_TAGS;"; + sqls[16] = "TRUNCATE TABLE NOTIFICATION_STATUS;"; + sqls[17] = "TRUNCATE TABLE USER_BADGES;"; + sqls[18] = "TRUNCATE TABLE NOTIFY_CONFIGS;"; + sqls[19] = "TRUNCATE TABLE MAIL_HOOKS;"; + sqls[20] = "TRUNCATE TABLE DRAFT_KNOWLEDGES;"; + sqls[21] = "TRUNCATE TABLE STOCK_KNOWLEDGES;"; + sqls[22] = "TRUNCATE TABLE KNOWLEDGE_USERS;"; + sqls[23] = "TRUNCATE TABLE PARTICIPANTS;"; + sqls[24] = "TRUNCATE TABLE TAGS;"; + sqls[25] = "TRUNCATE TABLE SERVICE_LOCALE_CONFIGS;"; + sqls[26] = "TRUNCATE TABLE ACCOUNT_IMAGES;"; + sqls[27] = "TRUNCATE TABLE MAIL_PROPERTIES;"; + sqls[28] = "TRUNCATE TABLE POINT_KNOWLEDGE_HISTORIES;"; + sqls[29] = "TRUNCATE TABLE MAIL_LOCALE_TEMPLATES;"; + sqls[30] = "TRUNCATE TABLE VOTES;"; + sqls[31] = "TRUNCATE TABLE COMMENTS;"; + sqls[32] = "TRUNCATE TABLE TOKENS;"; + sqls[33] = "TRUNCATE TABLE MAIL_HOOK_CONDITIONS;"; + sqls[34] = "TRUNCATE TABLE LIKES;"; + sqls[35] = "TRUNCATE TABLE VIEW_HISTORIES;"; + sqls[36] = "TRUNCATE TABLE SERVICE_CONFIGS;"; + sqls[37] = "TRUNCATE TABLE KNOWLEDGE_EDIT_USERS;"; + sqls[38] = "TRUNCATE TABLE PINS;"; + sqls[39] = "TRUNCATE TABLE KNOWLEDGE_HISTORIES;"; + sqls[40] = "TRUNCATE TABLE LIKE_COMMENTS;"; + sqls[41] = "TRUNCATE TABLE BADGES;"; + sqls[42] = "TRUNCATE TABLE SURVEY_ANSWERS;"; + sqls[43] = "TRUNCATE TABLE SURVEYS;"; + sqls[44] = "TRUNCATE TABLE ACTIVITIES;"; + sqls[45] = "TRUNCATE TABLE MAIL_HOOK_IGNORE_CONDITIONS;"; + sqls[46] = "TRUNCATE TABLE MAIL_TEMPLATES;"; + sqls[47] = "TRUNCATE TABLE POINT_USER_HISTORIES;"; + sqls[48] = "TRUNCATE TABLE SURVEY_ITEMS;"; + sqls[49] = "TRUNCATE TABLE STOCKS;"; + sqls[50] = "TRUNCATE TABLE TEMPLATE_ITEMS;"; for (String sql : sqls) { LOG.debug(sql); executeUpdate(sql); diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java index ca9d49904..d663bbdbf 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java @@ -13,8 +13,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -44,8 +46,19 @@ public static GenAccountImagesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, AccountImagesEntity.class); } /** @@ -54,8 +67,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, AccountImagesEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param imageId imageId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public AccountImagesEntity physicalSelectOnKey(Long imageId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, AccountImagesEntity.class, imageId); @@ -71,8 +98,19 @@ public AccountImagesEntity physicalSelectOnKey(Long imageId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, AccountImagesEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, AccountImagesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -98,6 +150,7 @@ public Integer selectCountAll() { * @param imageId imageId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public AccountImagesEntity selectOnKey(Long imageId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_on_key.sql"); return executeQuerySingle(sql, AccountImagesEntity.class, imageId); @@ -106,6 +159,7 @@ public AccountImagesEntity selectOnKey(Long imageId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM ACCOUNT_IMAGES"; return executeQuerySingle(sql, Integer.class); @@ -134,8 +188,13 @@ public AccountImagesEntity rawPhysicalInsert(AccountImagesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('ACCOUNT_IMAGES_IMAGE_ID_seq', (select max(IMAGE_ID) from ACCOUNT_IMAGES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(IMAGE_ID) from ACCOUNT_IMAGES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('ACCOUNT_IMAGES_IMAGE_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -174,9 +233,9 @@ public AccountImagesEntity physicalInsert(AccountImagesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public AccountImagesEntity insert(Integer user, AccountImagesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -229,7 +288,7 @@ public AccountImagesEntity update(Integer user, AccountImagesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -306,7 +365,7 @@ public void delete(Integer user, Long imageId) { AccountImagesEntity db = selectOnKey(imageId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -355,7 +414,7 @@ public void activation(Integer user, Long imageId) { AccountImagesEntity db = physicalSelectOnKey(imageId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenActivitiesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenActivitiesDao.java new file mode 100644 index 000000000..00cfb1372 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenActivitiesDao.java @@ -0,0 +1,444 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.ActivitiesEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * アクティビティ + * this class is auto generate and not edit. + * if modify dao method, you can edit ActivitiesDao. + */ +@DI(instance = Instance.Singleton) +public class GenActivitiesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenActivitiesDao get() { + return Container.getComp(GenActivitiesDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, ActivitiesEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, ActivitiesEntity.class, limit, offset); + } + /** + * Select data on key. + * @param activityNo activityNo + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity physicalSelectOnKey(Long activityNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, ActivitiesEntity.class, activityNo); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, ActivitiesEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, ActivitiesEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param activityNo activityNo + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity selectOnKey(Long activityNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_on_key.sql"); + return executeQuerySingle(sql, ActivitiesEntity.class, activityNo); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM ACTIVITIES"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity rawPhysicalInsert(ActivitiesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getActivityNo(), + entity.getUserId(), + entity.getKind(), + entity.getTarget(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String maxSql = "SELECT MAX(ACTIVITY_NO) from ACTIVITIES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('ACTIVITIES_ACTIVITY_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); + } + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity physicalInsert(ActivitiesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_insert.sql"); + Class type = PropertyUtil.getPropertyType(entity, "activityNo"); + Object key = executeInsert(sql, type, + entity.getUserId(), + entity.getKind(), + entity.getTarget(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + PropertyUtil.setPropertyValue(entity, "activityNo", key); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity insert(Integer user, ActivitiesEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity insert(ActivitiesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity physicalUpdate(ActivitiesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_update.sql"); + executeUpdate(sql, + entity.getUserId(), + entity.getKind(), + entity.getTarget(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getActivityNo()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity update(Integer user, ActivitiesEntity entity) { + ActivitiesEntity db = selectOnKey(entity.getActivityNo()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity update(ActivitiesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity save(Integer user, ActivitiesEntity entity) { + ActivitiesEntity db = selectOnKey(entity.getActivityNo()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public ActivitiesEntity save(ActivitiesEntity entity) { + ActivitiesEntity db = selectOnKey(entity.getActivityNo()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param activityNo activityNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Long activityNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_delete.sql"); + executeUpdate(sql, activityNo); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(ActivitiesEntity entity) { + physicalDelete(entity.getActivityNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param activityNo activityNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Long activityNo) { + ActivitiesEntity db = selectOnKey(activityNo); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param activityNo activityNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Long activityNo) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, activityNo); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, ActivitiesEntity entity) { + delete(user, entity.getActivityNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(ActivitiesEntity entity) { + delete(entity.getActivityNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param activityNo activityNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Long activityNo) { + ActivitiesEntity db = physicalSelectOnKey(activityNo); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param activityNo activityNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Long activityNo) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, activityNo); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, ActivitiesEntity entity) { + activation(user, entity.getActivityNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(ActivitiesEntity entity) { + activation(entity.getActivityNo()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenBadgesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenBadgesDao.java new file mode 100644 index 000000000..400501b74 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenBadgesDao.java @@ -0,0 +1,450 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.BadgesEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * 称号 + * this class is auto generate and not edit. + * if modify dao method, you can edit BadgesDao. + */ +@DI(instance = Instance.Singleton) +public class GenBadgesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenBadgesDao get() { + return Container.getComp(GenBadgesDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, BadgesEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, BadgesEntity.class, limit, offset); + } + /** + * Select data on key. + * @param no no + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity physicalSelectOnKey(Integer no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, BadgesEntity.class, no); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, BadgesEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, BadgesEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param no no + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity selectOnKey(Integer no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_on_key.sql"); + return executeQuerySingle(sql, BadgesEntity.class, no); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM BADGES"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity rawPhysicalInsert(BadgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getNo(), + entity.getName(), + entity.getDisplayText(), + entity.getDescription(), + entity.getImage(), + entity.getPoint(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String maxSql = "SELECT MAX(NO) from BADGES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('BADGES_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); + } + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity physicalInsert(BadgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_insert.sql"); + Class type = PropertyUtil.getPropertyType(entity, "no"); + Object key = executeInsert(sql, type, + entity.getName(), + entity.getDisplayText(), + entity.getDescription(), + entity.getImage(), + entity.getPoint(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + PropertyUtil.setPropertyValue(entity, "no", key); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity insert(Integer user, BadgesEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity insert(BadgesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity physicalUpdate(BadgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_update.sql"); + executeUpdate(sql, + entity.getName(), + entity.getDisplayText(), + entity.getDescription(), + entity.getImage(), + entity.getPoint(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getNo()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity update(Integer user, BadgesEntity entity) { + BadgesEntity db = selectOnKey(entity.getNo()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity update(BadgesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity save(Integer user, BadgesEntity entity) { + BadgesEntity db = selectOnKey(entity.getNo()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public BadgesEntity save(BadgesEntity entity) { + BadgesEntity db = selectOnKey(entity.getNo()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Integer no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_delete.sql"); + executeUpdate(sql, no); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(BadgesEntity entity) { + physicalDelete(entity.getNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Integer no) { + BadgesEntity db = selectOnKey(no); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer no) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, no); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, BadgesEntity entity) { + delete(user, entity.getNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(BadgesEntity entity) { + delete(entity.getNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Integer no) { + BadgesEntity db = physicalSelectOnKey(no); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer no) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, no); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, BadgesEntity entity) { + activation(user, entity.getNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(BadgesEntity entity) { + activation(entity.getNo()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java index 58fe6004a..49a2a32b1 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenCommentsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, CommentsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, CommentsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param commentNo commentNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public CommentsEntity physicalSelectOnKey(Long commentNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, CommentsEntity.class, commentNo); @@ -70,8 +97,19 @@ public CommentsEntity physicalSelectOnKey(Long commentNo) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, CommentsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, CommentsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param commentNo commentNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public CommentsEntity selectOnKey(Long commentNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_on_key.sql"); return executeQuerySingle(sql, CommentsEntity.class, commentNo); @@ -105,6 +158,7 @@ public CommentsEntity selectOnKey(Long commentNo) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM COMMENTS"; return executeQuerySingle(sql, Integer.class); @@ -130,8 +184,13 @@ public CommentsEntity rawPhysicalInsert(CommentsEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('COMMENTS_COMMENT_NO_seq', (select max(COMMENT_NO) from COMMENTS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(COMMENT_NO) from COMMENTS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('COMMENTS_COMMENT_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -167,9 +226,9 @@ public CommentsEntity physicalInsert(CommentsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public CommentsEntity insert(Integer user, CommentsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -219,7 +278,7 @@ public CommentsEntity update(Integer user, CommentsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -296,7 +355,7 @@ public void delete(Integer user, Long commentNo) { CommentsEntity db = selectOnKey(commentNo); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -345,7 +404,7 @@ public void activation(Integer user, Long commentNo) { CommentsEntity db = physicalSelectOnKey(commentNo); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenDraftItemValuesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenDraftItemValuesDao.java index 9ae137501..6bc62c327 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenDraftItemValuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenDraftItemValuesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenDraftItemValuesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftItemValuesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftItemValuesEntity.class, limit, offset); } /** @@ -64,6 +90,7 @@ public List physicalSelectAllWithPager(int limit, int off * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftItemValuesEntity physicalSelectOnKey(Long draftId, Integer itemNo, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, DraftItemValuesEntity.class, draftId, itemNo, typeId); @@ -72,8 +99,19 @@ public DraftItemValuesEntity physicalSelectOnKey(Long draftId, Integer itemNo, I * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftItemValuesEntity.class); } /** @@ -82,14 +120,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftItemValuesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -101,6 +153,7 @@ public Integer selectCountAll() { * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftItemValuesEntity selectOnKey(Long draftId, Integer itemNo, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_on_key.sql"); return executeQuerySingle(sql, DraftItemValuesEntity.class, draftId, itemNo, typeId); @@ -110,6 +163,7 @@ public DraftItemValuesEntity selectOnKey(Long draftId, Integer itemNo, Integer t * @param draftId draftId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnDraftId(Long draftId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_on_draft_id.sql"); return executeQueryList(sql, DraftItemValuesEntity.class, draftId); @@ -119,6 +173,7 @@ public List selectOnDraftId(Long draftId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_on_item_no.sql"); return executeQueryList(sql, DraftItemValuesEntity.class, itemNo); @@ -128,6 +183,7 @@ public List selectOnItemNo(Integer itemNo) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_on_type_id.sql"); return executeQueryList(sql, DraftItemValuesEntity.class, typeId); @@ -137,6 +193,7 @@ public List selectOnTypeId(Integer typeId) { * @param draftId draftId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnDraftId(Long draftId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_on_draft_id.sql"); return executeQueryList(sql, DraftItemValuesEntity.class, draftId); @@ -146,6 +203,7 @@ public List physicalSelectOnDraftId(Long draftId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_on_item_no.sql"); return executeQueryList(sql, DraftItemValuesEntity.class, itemNo); @@ -155,6 +213,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_on_type_id.sql"); return executeQueryList(sql, DraftItemValuesEntity.class, typeId); @@ -163,6 +222,7 @@ public List physicalSelectOnTypeId(Integer typeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM DRAFT_ITEM_VALUES"; return executeQuerySingle(sql, Integer.class); @@ -221,9 +281,9 @@ public DraftItemValuesEntity physicalInsert(DraftItemValuesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftItemValuesEntity insert(Integer user, DraftItemValuesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -274,7 +334,7 @@ public DraftItemValuesEntity update(Integer user, DraftItemValuesEntity entity) entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -355,7 +415,7 @@ public void delete(Integer user, Long draftId, Integer itemNo, Integer typeId) { DraftItemValuesEntity db = selectOnKey(draftId, itemNo, typeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -408,7 +468,7 @@ public void activation(Integer user, Long draftId, Integer itemNo, Integer typeI DraftItemValuesEntity db = physicalSelectOnKey(draftId, itemNo, typeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenDraftKnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenDraftKnowledgesDao.java index 32e39228b..186c06cea 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenDraftKnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenDraftKnowledgesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenDraftKnowledgesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftKnowledgesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftKnowledgesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int off * @param draftId draftId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftKnowledgesEntity physicalSelectOnKey(Long draftId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, DraftKnowledgesEntity.class, draftId); @@ -70,8 +97,19 @@ public DraftKnowledgesEntity physicalSelectOnKey(Long draftId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftKnowledgesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, DraftKnowledgesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param draftId draftId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftKnowledgesEntity selectOnKey(Long draftId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_on_key.sql"); return executeQuerySingle(sql, DraftKnowledgesEntity.class, draftId); @@ -105,6 +158,7 @@ public DraftKnowledgesEntity selectOnKey(Long draftId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM DRAFT_KNOWLEDGES"; return executeQuerySingle(sql, Integer.class); @@ -135,8 +189,13 @@ public DraftKnowledgesEntity rawPhysicalInsert(DraftKnowledgesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('DRAFT_KNOWLEDGES_DRAFT_ID_seq', (select max(DRAFT_ID) from DRAFT_KNOWLEDGES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(DRAFT_ID) from DRAFT_KNOWLEDGES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('DRAFT_KNOWLEDGES_DRAFT_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -177,9 +236,9 @@ public DraftKnowledgesEntity physicalInsert(DraftKnowledgesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public DraftKnowledgesEntity insert(Integer user, DraftKnowledgesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -234,7 +293,7 @@ public DraftKnowledgesEntity update(Integer user, DraftKnowledgesEntity entity) entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -311,7 +370,7 @@ public void delete(Integer user, Long draftId) { DraftKnowledgesEntity db = selectOnKey(draftId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -360,7 +419,7 @@ public void activation(Integer user, Long draftId) { DraftKnowledgesEntity db = physicalSelectOnKey(draftId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenEventsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenEventsDao.java index a67a057e1..0d52950ef 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenEventsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenEventsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenEventsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, EventsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, EventsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public EventsEntity physicalSelectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, EventsEntity.class, knowledgeId); @@ -70,8 +97,19 @@ public EventsEntity physicalSelectOnKey(Long knowledgeId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, EventsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, EventsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public EventsEntity selectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_on_key.sql"); return executeQuerySingle(sql, EventsEntity.class, knowledgeId); @@ -105,6 +158,7 @@ public EventsEntity selectOnKey(Long knowledgeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM EVENTS"; return executeQuerySingle(sql, Integer.class); @@ -161,9 +215,9 @@ public EventsEntity physicalInsert(EventsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public EventsEntity insert(Integer user, EventsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -213,7 +267,7 @@ public EventsEntity update(Integer user, EventsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -290,7 +344,7 @@ public void delete(Integer user, Long knowledgeId) { EventsEntity db = selectOnKey(knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -339,7 +393,7 @@ public void activation(Integer user, Long knowledgeId) { EventsEntity db = physicalSelectOnKey(knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenItemChoicesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenItemChoicesDao.java index 3d45fed52..cbbc3f915 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenItemChoicesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenItemChoicesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenItemChoicesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ItemChoicesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ItemChoicesEntity.class, limit, offset); } /** @@ -64,6 +90,7 @@ public List physicalSelectAllWithPager(int limit, int offset) * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ItemChoicesEntity physicalSelectOnKey(Integer choiceNo, Integer itemNo, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, ItemChoicesEntity.class, choiceNo, itemNo, typeId); @@ -72,8 +99,19 @@ public ItemChoicesEntity physicalSelectOnKey(Integer choiceNo, Integer itemNo, I * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ItemChoicesEntity.class); } /** @@ -82,14 +120,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ItemChoicesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -101,6 +153,7 @@ public Integer selectCountAll() { * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ItemChoicesEntity selectOnKey(Integer choiceNo, Integer itemNo, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_on_key.sql"); return executeQuerySingle(sql, ItemChoicesEntity.class, choiceNo, itemNo, typeId); @@ -110,6 +163,7 @@ public ItemChoicesEntity selectOnKey(Integer choiceNo, Integer itemNo, Integer t * @param choiceNo choiceNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnChoiceNo(Integer choiceNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_on_choice_no.sql"); return executeQueryList(sql, ItemChoicesEntity.class, choiceNo); @@ -119,6 +173,7 @@ public List selectOnChoiceNo(Integer choiceNo) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_on_item_no.sql"); return executeQueryList(sql, ItemChoicesEntity.class, itemNo); @@ -128,6 +183,7 @@ public List selectOnItemNo(Integer itemNo) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_on_type_id.sql"); return executeQueryList(sql, ItemChoicesEntity.class, typeId); @@ -137,6 +193,7 @@ public List selectOnTypeId(Integer typeId) { * @param choiceNo choiceNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnChoiceNo(Integer choiceNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_on_choice_no.sql"); return executeQueryList(sql, ItemChoicesEntity.class, choiceNo); @@ -146,6 +203,7 @@ public List physicalSelectOnChoiceNo(Integer choiceNo) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_on_item_no.sql"); return executeQueryList(sql, ItemChoicesEntity.class, itemNo); @@ -155,6 +213,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_on_type_id.sql"); return executeQueryList(sql, ItemChoicesEntity.class, typeId); @@ -163,6 +222,7 @@ public List physicalSelectOnTypeId(Integer typeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM ITEM_CHOICES"; return executeQuerySingle(sql, Integer.class); @@ -221,9 +281,9 @@ public ItemChoicesEntity physicalInsert(ItemChoicesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ItemChoicesEntity insert(Integer user, ItemChoicesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -274,7 +334,7 @@ public ItemChoicesEntity update(Integer user, ItemChoicesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -355,7 +415,7 @@ public void delete(Integer user, Integer choiceNo, Integer itemNo, Integer typeI ItemChoicesEntity db = selectOnKey(choiceNo, itemNo, typeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -408,7 +468,7 @@ public void activation(Integer user, Integer choiceNo, Integer itemNo, Integer t ItemChoicesEntity db = physicalSelectOnKey(choiceNo, itemNo, typeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditGroupsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditGroupsDao.java index 10293959e..5872a1a26 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditGroupsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditGroupsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeEditGroupsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditGroupsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditGroupsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeEditGroupsEntity physicalSelectOnKey(Integer groupId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeEditGroupsEntity.class, groupId, knowledgeId); @@ -71,8 +98,19 @@ public KnowledgeEditGroupsEntity physicalSelectOnKey(Integer groupId, Long knowl * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditGroupsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditGroupsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeEditGroupsEntity selectOnKey(Integer groupId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeEditGroupsEntity.class, groupId, knowledgeId); @@ -108,6 +161,7 @@ public KnowledgeEditGroupsEntity selectOnKey(Integer groupId, Long knowledgeId) * @param groupId groupId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnGroupId(Integer groupId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_on_group_id.sql"); return executeQueryList(sql, KnowledgeEditGroupsEntity.class, groupId); @@ -117,6 +171,7 @@ public List selectOnGroupId(Integer groupId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeEditGroupsEntity.class, knowledgeId); @@ -126,6 +181,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param groupId groupId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnGroupId(Integer groupId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_on_group_id.sql"); return executeQueryList(sql, KnowledgeEditGroupsEntity.class, groupId); @@ -135,6 +191,7 @@ public List physicalSelectOnGroupId(Integer groupId) * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeEditGroupsEntity.class, knowledgeId); @@ -143,6 +200,7 @@ public List physicalSelectOnKnowledgeId(Long knowledg * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_EDIT_GROUPS"; return executeQuerySingle(sql, Integer.class); @@ -195,9 +253,9 @@ public KnowledgeEditGroupsEntity physicalInsert(KnowledgeEditGroupsEntity entity @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeEditGroupsEntity insert(Integer user, KnowledgeEditGroupsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -245,7 +303,7 @@ public KnowledgeEditGroupsEntity update(Integer user, KnowledgeEditGroupsEntity entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -324,7 +382,7 @@ public void delete(Integer user, Integer groupId, Long knowledgeId) { KnowledgeEditGroupsEntity db = selectOnKey(groupId, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -375,7 +433,7 @@ public void activation(Integer user, Integer groupId, Long knowledgeId) { KnowledgeEditGroupsEntity db = physicalSelectOnKey(groupId, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditUsersDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditUsersDao.java index f57274531..a00c330bd 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeEditUsersDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeEditUsersDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditUsersEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditUsersEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeEditUsersEntity physicalSelectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeEditUsersEntity.class, knowledgeId, userId); @@ -71,8 +98,19 @@ public KnowledgeEditUsersEntity physicalSelectOnKey(Long knowledgeId, Integer us * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditUsersEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeEditUsersEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeEditUsersEntity selectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeEditUsersEntity.class, knowledgeId, userId); @@ -108,6 +161,7 @@ public KnowledgeEditUsersEntity selectOnKey(Long knowledgeId, Integer userId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeEditUsersEntity.class, knowledgeId); @@ -117,6 +171,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param userId userId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_on_user_id.sql"); return executeQueryList(sql, KnowledgeEditUsersEntity.class, userId); @@ -126,6 +181,7 @@ public List selectOnUserId(Integer userId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeEditUsersEntity.class, knowledgeId); @@ -135,6 +191,7 @@ public List physicalSelectOnKnowledgeId(Long knowledge * @param userId userId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_on_user_id.sql"); return executeQueryList(sql, KnowledgeEditUsersEntity.class, userId); @@ -143,6 +200,7 @@ public List physicalSelectOnUserId(Integer userId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_EDIT_USERS"; return executeQuerySingle(sql, Integer.class); @@ -195,9 +253,9 @@ public KnowledgeEditUsersEntity physicalInsert(KnowledgeEditUsersEntity entity) @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeEditUsersEntity insert(Integer user, KnowledgeEditUsersEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -245,7 +303,7 @@ public KnowledgeEditUsersEntity update(Integer user, KnowledgeEditUsersEntity en entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -324,7 +382,7 @@ public void delete(Integer user, Long knowledgeId, Integer userId) { KnowledgeEditUsersEntity db = selectOnKey(knowledgeId, userId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -375,7 +433,7 @@ public void activation(Integer user, Long knowledgeId, Integer userId) { KnowledgeEditUsersEntity db = physicalSelectOnKey(knowledgeId, userId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java index dd5f775b0..01f55d4eb 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java @@ -13,8 +13,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -44,8 +46,19 @@ public static GenKnowledgeFilesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeFilesEntity.class); } /** @@ -54,8 +67,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeFilesEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offs * @param fileNo fileNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeFilesEntity physicalSelectOnKey(Long fileNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeFilesEntity.class, fileNo); @@ -71,8 +98,19 @@ public KnowledgeFilesEntity physicalSelectOnKey(Long fileNo) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeFilesEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeFilesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -98,6 +150,7 @@ public Integer selectCountAll() { * @param fileNo fileNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeFilesEntity selectOnKey(Long fileNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeFilesEntity.class, fileNo); @@ -106,6 +159,7 @@ public KnowledgeFilesEntity selectOnKey(Long fileNo) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_FILES"; return executeQuerySingle(sql, Integer.class); @@ -135,8 +189,13 @@ public KnowledgeFilesEntity rawPhysicalInsert(KnowledgeFilesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('KNOWLEDGE_FILES_FILE_NO_seq', (select max(FILE_NO) from KNOWLEDGE_FILES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(FILE_NO) from KNOWLEDGE_FILES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('KNOWLEDGE_FILES_FILE_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -176,9 +235,9 @@ public KnowledgeFilesEntity physicalInsert(KnowledgeFilesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeFilesEntity insert(Integer user, KnowledgeFilesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -232,7 +291,7 @@ public KnowledgeFilesEntity update(Integer user, KnowledgeFilesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -309,7 +368,7 @@ public void delete(Integer user, Long fileNo) { KnowledgeFilesEntity db = selectOnKey(fileNo); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -358,7 +417,7 @@ public void activation(Integer user, Long fileNo) { KnowledgeFilesEntity db = physicalSelectOnKey(fileNo); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java index a2192177a..efd46954f 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeGroupsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeGroupsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeGroupsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int off * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeGroupsEntity physicalSelectOnKey(Integer groupId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeGroupsEntity.class, groupId, knowledgeId); @@ -71,8 +98,19 @@ public KnowledgeGroupsEntity physicalSelectOnKey(Integer groupId, Long knowledge * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeGroupsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeGroupsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeGroupsEntity selectOnKey(Integer groupId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeGroupsEntity.class, groupId, knowledgeId); @@ -108,6 +161,7 @@ public KnowledgeGroupsEntity selectOnKey(Integer groupId, Long knowledgeId) { * @param groupId groupId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnGroupId(Integer groupId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_on_group_id.sql"); return executeQueryList(sql, KnowledgeGroupsEntity.class, groupId); @@ -117,6 +171,7 @@ public List selectOnGroupId(Integer groupId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeGroupsEntity.class, knowledgeId); @@ -126,6 +181,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param groupId groupId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnGroupId(Integer groupId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_on_group_id.sql"); return executeQueryList(sql, KnowledgeGroupsEntity.class, groupId); @@ -135,6 +191,7 @@ public List physicalSelectOnGroupId(Integer groupId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeGroupsEntity.class, knowledgeId); @@ -143,6 +200,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_GROUPS"; return executeQuerySingle(sql, Integer.class); @@ -195,9 +253,9 @@ public KnowledgeGroupsEntity physicalInsert(KnowledgeGroupsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeGroupsEntity insert(Integer user, KnowledgeGroupsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -245,7 +303,7 @@ public KnowledgeGroupsEntity update(Integer user, KnowledgeGroupsEntity entity) entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -324,7 +382,7 @@ public void delete(Integer user, Integer groupId, Long knowledgeId) { KnowledgeGroupsEntity db = selectOnKey(groupId, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -375,7 +433,7 @@ public void activation(Integer user, Integer groupId, Long knowledgeId) { KnowledgeGroupsEntity db = physicalSelectOnKey(groupId, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java index 46ad29627..acea7ef99 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeHistoriesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeHistoriesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeHistoriesEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeHistoriesEntity physicalSelectOnKey(Integer historyNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeHistoriesEntity.class, historyNo, knowledgeId); @@ -71,8 +98,19 @@ public KnowledgeHistoriesEntity physicalSelectOnKey(Integer historyNo, Long know * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeHistoriesEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeHistoriesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeHistoriesEntity selectOnKey(Integer historyNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeHistoriesEntity.class, historyNo, knowledgeId); @@ -108,6 +161,7 @@ public KnowledgeHistoriesEntity selectOnKey(Integer historyNo, Long knowledgeId) * @param historyNo historyNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnHistoryNo(Integer historyNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_history_no.sql"); return executeQueryList(sql, KnowledgeHistoriesEntity.class, historyNo); @@ -117,6 +171,7 @@ public List selectOnHistoryNo(Integer historyNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeHistoriesEntity.class, knowledgeId); @@ -126,6 +181,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param historyNo historyNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnHistoryNo(Integer historyNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_history_no.sql"); return executeQueryList(sql, KnowledgeHistoriesEntity.class, historyNo); @@ -135,6 +191,7 @@ public List physicalSelectOnHistoryNo(Integer historyN * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeHistoriesEntity.class, knowledgeId); @@ -143,6 +200,7 @@ public List physicalSelectOnKnowledgeId(Long knowledge * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_HISTORIES"; return executeQuerySingle(sql, Integer.class); @@ -209,9 +267,9 @@ public KnowledgeHistoriesEntity physicalInsert(KnowledgeHistoriesEntity entity) @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeHistoriesEntity insert(Integer user, KnowledgeHistoriesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -266,7 +324,7 @@ public KnowledgeHistoriesEntity update(Integer user, KnowledgeHistoriesEntity en entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -345,7 +403,7 @@ public void delete(Integer user, Integer historyNo, Long knowledgeId) { KnowledgeHistoriesEntity db = selectOnKey(historyNo, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -396,7 +454,7 @@ public void activation(Integer user, Integer historyNo, Long knowledgeId) { KnowledgeHistoriesEntity db = physicalSelectOnKey(historyNo, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeItemValuesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeItemValuesDao.java index 8f1a94493..03f3341e2 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeItemValuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeItemValuesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeItemValuesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeItemValuesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeItemValuesEntity.class, limit, offset); } /** @@ -64,6 +90,7 @@ public List physicalSelectAllWithPager(int limit, int * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeItemValuesEntity physicalSelectOnKey(Integer itemNo, Long knowledgeId, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeItemValuesEntity.class, itemNo, knowledgeId, typeId); @@ -72,8 +99,19 @@ public KnowledgeItemValuesEntity physicalSelectOnKey(Integer itemNo, Long knowle * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeItemValuesEntity.class); } /** @@ -82,14 +120,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeItemValuesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -101,6 +153,7 @@ public Integer selectCountAll() { * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeItemValuesEntity selectOnKey(Integer itemNo, Long knowledgeId, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeItemValuesEntity.class, itemNo, knowledgeId, typeId); @@ -110,6 +163,7 @@ public KnowledgeItemValuesEntity selectOnKey(Integer itemNo, Long knowledgeId, I * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_on_item_no.sql"); return executeQueryList(sql, KnowledgeItemValuesEntity.class, itemNo); @@ -119,6 +173,7 @@ public List selectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeItemValuesEntity.class, knowledgeId); @@ -128,6 +183,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_on_type_id.sql"); return executeQueryList(sql, KnowledgeItemValuesEntity.class, typeId); @@ -137,6 +193,7 @@ public List selectOnTypeId(Integer typeId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_on_item_no.sql"); return executeQueryList(sql, KnowledgeItemValuesEntity.class, itemNo); @@ -146,6 +203,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeItemValuesEntity.class, knowledgeId); @@ -155,6 +213,7 @@ public List physicalSelectOnKnowledgeId(Long knowledg * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_on_type_id.sql"); return executeQueryList(sql, KnowledgeItemValuesEntity.class, typeId); @@ -163,6 +222,7 @@ public List physicalSelectOnTypeId(Integer typeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_ITEM_VALUES"; return executeQuerySingle(sql, Integer.class); @@ -221,9 +281,9 @@ public KnowledgeItemValuesEntity physicalInsert(KnowledgeItemValuesEntity entity @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeItemValuesEntity insert(Integer user, KnowledgeItemValuesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -274,7 +334,7 @@ public KnowledgeItemValuesEntity update(Integer user, KnowledgeItemValuesEntity entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -355,7 +415,7 @@ public void delete(Integer user, Integer itemNo, Long knowledgeId, Integer typeI KnowledgeItemValuesEntity db = selectOnKey(itemNo, knowledgeId, typeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -408,7 +468,7 @@ public void activation(Integer user, Integer itemNo, Long knowledgeId, Integer t KnowledgeItemValuesEntity db = physicalSelectOnKey(itemNo, knowledgeId, typeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java index f3ddcbeeb..a370ff68c 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeTagsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeTagsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeTagsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param tagId tagId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeTagsEntity physicalSelectOnKey(Long knowledgeId, Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeTagsEntity.class, knowledgeId, tagId); @@ -71,8 +98,19 @@ public KnowledgeTagsEntity physicalSelectOnKey(Long knowledgeId, Integer tagId) * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeTagsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeTagsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param tagId tagId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeTagsEntity selectOnKey(Long knowledgeId, Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeTagsEntity.class, knowledgeId, tagId); @@ -108,6 +161,7 @@ public KnowledgeTagsEntity selectOnKey(Long knowledgeId, Integer tagId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeTagsEntity.class, knowledgeId); @@ -117,6 +171,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param tagId tagId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTagId(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_on_tag_id.sql"); return executeQueryList(sql, KnowledgeTagsEntity.class, tagId); @@ -126,6 +181,7 @@ public List selectOnTagId(Integer tagId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeTagsEntity.class, knowledgeId); @@ -135,6 +191,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) { * @param tagId tagId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnTagId(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_on_tag_id.sql"); return executeQueryList(sql, KnowledgeTagsEntity.class, tagId); @@ -143,6 +200,7 @@ public List physicalSelectOnTagId(Integer tagId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_TAGS"; return executeQuerySingle(sql, Integer.class); @@ -195,9 +253,9 @@ public KnowledgeTagsEntity physicalInsert(KnowledgeTagsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeTagsEntity insert(Integer user, KnowledgeTagsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -245,7 +303,7 @@ public KnowledgeTagsEntity update(Integer user, KnowledgeTagsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -324,7 +382,7 @@ public void delete(Integer user, Long knowledgeId, Integer tagId) { KnowledgeTagsEntity db = selectOnKey(knowledgeId, tagId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -375,7 +433,7 @@ public void activation(Integer user, Long knowledgeId, Integer tagId) { KnowledgeTagsEntity db = physicalSelectOnKey(knowledgeId, tagId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java index 3d246f340..7b92c2901 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgeUsersDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeUsersEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeUsersEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offs * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeUsersEntity physicalSelectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeUsersEntity.class, knowledgeId, userId); @@ -71,8 +98,19 @@ public KnowledgeUsersEntity physicalSelectOnKey(Long knowledgeId, Integer userId * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeUsersEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgeUsersEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeUsersEntity selectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgeUsersEntity.class, knowledgeId, userId); @@ -108,6 +161,7 @@ public KnowledgeUsersEntity selectOnKey(Long knowledgeId, Integer userId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeUsersEntity.class, knowledgeId); @@ -117,6 +171,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param userId userId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_on_user_id.sql"); return executeQueryList(sql, KnowledgeUsersEntity.class, userId); @@ -126,6 +181,7 @@ public List selectOnUserId(Integer userId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, KnowledgeUsersEntity.class, knowledgeId); @@ -135,6 +191,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) * @param userId userId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_on_user_id.sql"); return executeQueryList(sql, KnowledgeUsersEntity.class, userId); @@ -143,6 +200,7 @@ public List physicalSelectOnUserId(Integer userId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGE_USERS"; return executeQuerySingle(sql, Integer.class); @@ -195,9 +253,9 @@ public KnowledgeUsersEntity physicalInsert(KnowledgeUsersEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgeUsersEntity insert(Integer user, KnowledgeUsersEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -245,7 +303,7 @@ public KnowledgeUsersEntity update(Integer user, KnowledgeUsersEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -324,7 +382,7 @@ public void delete(Integer user, Long knowledgeId, Integer userId) { KnowledgeUsersEntity db = selectOnKey(knowledgeId, userId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -375,7 +433,7 @@ public void activation(Integer user, Long knowledgeId, Integer userId) { KnowledgeUsersEntity db = physicalSelectOnKey(knowledgeId, userId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java index eed483399..abac38dc4 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenKnowledgesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgesEntity physicalSelectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, KnowledgesEntity.class, knowledgeId); @@ -70,8 +97,19 @@ public KnowledgesEntity physicalSelectOnKey(Long knowledgeId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, KnowledgesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgesEntity selectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_on_key.sql"); return executeQuerySingle(sql, KnowledgesEntity.class, knowledgeId); @@ -105,6 +158,7 @@ public KnowledgesEntity selectOnKey(Long knowledgeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM KNOWLEDGES"; return executeQuerySingle(sql, Integer.class); @@ -127,8 +181,10 @@ public KnowledgesEntity rawPhysicalInsert(KnowledgesEntity entity) { entity.getTagNames(), entity.getLikeCount(), entity.getCommentCount(), + entity.getViewCount(), entity.getTypeId(), entity.getNotifyStatus(), + entity.getPoint(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -136,8 +192,13 @@ public KnowledgesEntity rawPhysicalInsert(KnowledgesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('KNOWLEDGES_KNOWLEDGE_ID_seq', (select max(KNOWLEDGE_ID) from KNOWLEDGES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(KNOWLEDGE_ID) from KNOWLEDGES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('KNOWLEDGES_KNOWLEDGE_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -159,8 +220,10 @@ public KnowledgesEntity physicalInsert(KnowledgesEntity entity) { entity.getTagNames(), entity.getLikeCount(), entity.getCommentCount(), + entity.getViewCount(), entity.getTypeId(), entity.getNotifyStatus(), + entity.getPoint(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -179,9 +242,9 @@ public KnowledgesEntity physicalInsert(KnowledgesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public KnowledgesEntity insert(Integer user, KnowledgesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -213,8 +276,10 @@ public KnowledgesEntity physicalUpdate(KnowledgesEntity entity) { entity.getTagNames(), entity.getLikeCount(), entity.getCommentCount(), + entity.getViewCount(), entity.getTypeId(), entity.getNotifyStatus(), + entity.getPoint(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -237,7 +302,7 @@ public KnowledgesEntity update(Integer user, KnowledgesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -314,7 +379,7 @@ public void delete(Integer user, Long knowledgeId) { KnowledgesEntity db = selectOnKey(knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -363,7 +428,7 @@ public void activation(Integer user, Long knowledgeId) { KnowledgesEntity db = physicalSelectOnKey(knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenLikeCommentsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenLikeCommentsDao.java new file mode 100644 index 000000000..05757fbc5 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenLikeCommentsDao.java @@ -0,0 +1,441 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.LikeCommentsEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * コメントのイイネ + * this class is auto generate and not edit. + * if modify dao method, you can edit LikeCommentsDao. + */ +@DI(instance = Instance.Singleton) +public class GenLikeCommentsDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenLikeCommentsDao get() { + return Container.getComp(GenLikeCommentsDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, LikeCommentsEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, LikeCommentsEntity.class, limit, offset); + } + /** + * Select data on key. + * @param no no + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity physicalSelectOnKey(Long no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, LikeCommentsEntity.class, no); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, LikeCommentsEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, LikeCommentsEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param no no + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity selectOnKey(Long no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_on_key.sql"); + return executeQuerySingle(sql, LikeCommentsEntity.class, no); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM LIKE_COMMENTS"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity rawPhysicalInsert(LikeCommentsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getNo(), + entity.getCommentNo(), + entity.getLikeClass(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String maxSql = "SELECT MAX(NO) from LIKE_COMMENTS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('LIKE_COMMENTS_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); + } + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity physicalInsert(LikeCommentsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_insert.sql"); + Class type = PropertyUtil.getPropertyType(entity, "no"); + Object key = executeInsert(sql, type, + entity.getCommentNo(), + entity.getLikeClass(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + PropertyUtil.setPropertyValue(entity, "no", key); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity insert(Integer user, LikeCommentsEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity insert(LikeCommentsEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity physicalUpdate(LikeCommentsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_update.sql"); + executeUpdate(sql, + entity.getCommentNo(), + entity.getLikeClass(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getNo()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity update(Integer user, LikeCommentsEntity entity) { + LikeCommentsEntity db = selectOnKey(entity.getNo()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity update(LikeCommentsEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity save(Integer user, LikeCommentsEntity entity) { + LikeCommentsEntity db = selectOnKey(entity.getNo()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public LikeCommentsEntity save(LikeCommentsEntity entity) { + LikeCommentsEntity db = selectOnKey(entity.getNo()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Long no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_delete.sql"); + executeUpdate(sql, no); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(LikeCommentsEntity entity) { + physicalDelete(entity.getNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Long no) { + LikeCommentsEntity db = selectOnKey(no); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Long no) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, no); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, LikeCommentsEntity entity) { + delete(user, entity.getNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(LikeCommentsEntity entity) { + delete(entity.getNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Long no) { + LikeCommentsEntity db = physicalSelectOnKey(no); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param no no + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Long no) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, no); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, LikeCommentsEntity entity) { + activation(user, entity.getNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(LikeCommentsEntity entity) { + activation(entity.getNo()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java index 05791fe08..ebc2551cf 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenLikesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, LikesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, LikesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param no no * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public LikesEntity physicalSelectOnKey(Long no) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, LikesEntity.class, no); @@ -70,8 +97,19 @@ public LikesEntity physicalSelectOnKey(Long no) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, LikesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, LikesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param no no * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public LikesEntity selectOnKey(Long no) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_on_key.sql"); return executeQuerySingle(sql, LikesEntity.class, no); @@ -105,6 +158,7 @@ public LikesEntity selectOnKey(Long no) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM LIKES"; return executeQuerySingle(sql, Integer.class); @@ -121,6 +175,7 @@ public LikesEntity rawPhysicalInsert(LikesEntity entity) { executeUpdate(sql, entity.getNo(), entity.getKnowledgeId(), + entity.getLikeClass(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -128,8 +183,13 @@ public LikesEntity rawPhysicalInsert(LikesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('LIKES_NO_seq', (select max(NO) from LIKES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(NO) from LIKES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('LIKES_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -145,6 +205,7 @@ public LikesEntity physicalInsert(LikesEntity entity) { Class type = PropertyUtil.getPropertyType(entity, "no"); Object key = executeInsert(sql, type, entity.getKnowledgeId(), + entity.getLikeClass(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -163,9 +224,9 @@ public LikesEntity physicalInsert(LikesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public LikesEntity insert(Integer user, LikesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -191,6 +252,7 @@ public LikesEntity physicalUpdate(LikesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_update.sql"); executeUpdate(sql, entity.getKnowledgeId(), + entity.getLikeClass(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -213,7 +275,7 @@ public LikesEntity update(Integer user, LikesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -290,7 +352,7 @@ public void delete(Integer user, Long no) { LikesEntity db = selectOnKey(no); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -339,7 +401,7 @@ public void activation(Integer user, Long no) { LikesEntity db = physicalSelectOnKey(no); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookConditionsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookConditionsDao.java index 1f488fa5a..311984771 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookConditionsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookConditionsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenMailHookConditionsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHookConditionsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHookConditionsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int * @param hookId hookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHookConditionsEntity physicalSelectOnKey(Integer conditionNo, Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, MailHookConditionsEntity.class, conditionNo, hookId); @@ -71,8 +98,19 @@ public MailHookConditionsEntity physicalSelectOnKey(Integer conditionNo, Integer * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHookConditionsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHookConditionsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param hookId hookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHookConditionsEntity selectOnKey(Integer conditionNo, Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_on_key.sql"); return executeQuerySingle(sql, MailHookConditionsEntity.class, conditionNo, hookId); @@ -108,6 +161,7 @@ public MailHookConditionsEntity selectOnKey(Integer conditionNo, Integer hookId) * @param conditionNo conditionNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnConditionNo(Integer conditionNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_on_condition_no.sql"); return executeQueryList(sql, MailHookConditionsEntity.class, conditionNo); @@ -117,6 +171,7 @@ public List selectOnConditionNo(Integer conditionNo) { * @param hookId hookId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnHookId(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_on_hook_id.sql"); return executeQueryList(sql, MailHookConditionsEntity.class, hookId); @@ -126,6 +181,7 @@ public List selectOnHookId(Integer hookId) { * @param conditionNo conditionNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnConditionNo(Integer conditionNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_on_condition_no.sql"); return executeQueryList(sql, MailHookConditionsEntity.class, conditionNo); @@ -135,6 +191,7 @@ public List physicalSelectOnConditionNo(Integer condit * @param hookId hookId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnHookId(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_on_hook_id.sql"); return executeQueryList(sql, MailHookConditionsEntity.class, hookId); @@ -143,6 +200,7 @@ public List physicalSelectOnHookId(Integer hookId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM MAIL_HOOK_CONDITIONS"; return executeQuerySingle(sql, Integer.class); @@ -215,9 +273,9 @@ public MailHookConditionsEntity physicalInsert(MailHookConditionsEntity entity) @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHookConditionsEntity insert(Integer user, MailHookConditionsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -275,7 +333,7 @@ public MailHookConditionsEntity update(Integer user, MailHookConditionsEntity en entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -354,7 +412,7 @@ public void delete(Integer user, Integer conditionNo, Integer hookId) { MailHookConditionsEntity db = selectOnKey(conditionNo, hookId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -405,7 +463,7 @@ public void activation(Integer user, Integer conditionNo, Integer hookId) { MailHookConditionsEntity db = physicalSelectOnKey(conditionNo, hookId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookIgnoreConditionsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookIgnoreConditionsDao.java new file mode 100644 index 000000000..e6dfc0d44 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailHookIgnoreConditionsDao.java @@ -0,0 +1,510 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.MailHookIgnoreConditionsEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * メールから投稿の際の除外条件 + * this class is auto generate and not edit. + * if modify dao method, you can edit MailHookIgnoreConditionsDao. + */ +@DI(instance = Instance.Singleton) +public class GenMailHookIgnoreConditionsDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenMailHookIgnoreConditionsDao get() { + return Container.getComp(GenMailHookIgnoreConditionsDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, limit, offset); + } + /** + * Select data on key. + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity physicalSelectOnKey(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, MailHookIgnoreConditionsEntity.class, conditionNo, hookId, ignoreConditionNo); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity selectOnKey(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_key.sql"); + return executeQuerySingle(sql, MailHookIgnoreConditionsEntity.class, conditionNo, hookId, ignoreConditionNo); + } + /** + * Select data that not deleted on CONDITION_NO column. + * @param conditionNo conditionNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnConditionNo(Integer conditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_condition_no.sql"); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, conditionNo); + } + /** + * Select data that not deleted on HOOK_ID column. + * @param hookId hookId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnHookId(Integer hookId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_hook_id.sql"); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, hookId); + } + /** + * Select data that not deleted on IGNORE_CONDITION_NO column. + * @param ignoreConditionNo ignoreConditionNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnIgnoreConditionNo(Integer ignoreConditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_ignore_condition_no.sql"); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, ignoreConditionNo); + } + /** + * Select data on CONDITION_NO column. + * @param conditionNo conditionNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnConditionNo(Integer conditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_condition_no.sql"); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, conditionNo); + } + /** + * Select data on HOOK_ID column. + * @param hookId hookId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnHookId(Integer hookId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_hook_id.sql"); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, hookId); + } + /** + * Select data on IGNORE_CONDITION_NO column. + * @param ignoreConditionNo ignoreConditionNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnIgnoreConditionNo(Integer ignoreConditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_ignore_condition_no.sql"); + return executeQueryList(sql, MailHookIgnoreConditionsEntity.class, ignoreConditionNo); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM MAIL_HOOK_IGNORE_CONDITIONS"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity rawPhysicalInsert(MailHookIgnoreConditionsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getConditionNo(), + entity.getHookId(), + entity.getIgnoreConditionNo(), + entity.getConditionKind(), + entity.getCondition(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity physicalInsert(MailHookIgnoreConditionsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_insert.sql"); + executeUpdate(sql, + entity.getConditionNo(), + entity.getHookId(), + entity.getIgnoreConditionNo(), + entity.getConditionKind(), + entity.getCondition(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity insert(Integer user, MailHookIgnoreConditionsEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity insert(MailHookIgnoreConditionsEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity physicalUpdate(MailHookIgnoreConditionsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_update.sql"); + executeUpdate(sql, + entity.getConditionKind(), + entity.getCondition(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getConditionNo(), + entity.getHookId(), + entity.getIgnoreConditionNo()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity update(Integer user, MailHookIgnoreConditionsEntity entity) { + MailHookIgnoreConditionsEntity db = selectOnKey(entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity update(MailHookIgnoreConditionsEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity save(Integer user, MailHookIgnoreConditionsEntity entity) { + MailHookIgnoreConditionsEntity db = selectOnKey(entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailHookIgnoreConditionsEntity save(MailHookIgnoreConditionsEntity entity) { + MailHookIgnoreConditionsEntity db = selectOnKey(entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_delete.sql"); + executeUpdate(sql, conditionNo, hookId, ignoreConditionNo); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(MailHookIgnoreConditionsEntity entity) { + physicalDelete(entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + MailHookIgnoreConditionsEntity db = selectOnKey(conditionNo, hookId, ignoreConditionNo); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, conditionNo, hookId, ignoreConditionNo); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, MailHookIgnoreConditionsEntity entity) { + delete(user, entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(MailHookIgnoreConditionsEntity entity) { + delete(entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + MailHookIgnoreConditionsEntity db = physicalSelectOnKey(conditionNo, hookId, ignoreConditionNo); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param conditionNo conditionNo + * @param hookId hookId + * @param ignoreConditionNo ignoreConditionNo + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, conditionNo, hookId, ignoreConditionNo); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, MailHookIgnoreConditionsEntity entity) { + activation(user, entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(MailHookIgnoreConditionsEntity entity) { + activation(entity.getConditionNo(), entity.getHookId(), entity.getIgnoreConditionNo()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailHooksDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailHooksDao.java index 68196a8ea..65cee2dd9 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailHooksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailHooksDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenMailHooksDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHooksEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHooksEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param hookId hookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHooksEntity physicalSelectOnKey(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_on_key.sql"); return executeQuerySingle(sql, MailHooksEntity.class, hookId); @@ -70,8 +97,19 @@ public MailHooksEntity physicalSelectOnKey(Integer hookId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHooksEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailHooksEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param hookId hookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHooksEntity selectOnKey(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_on_key.sql"); return executeQuerySingle(sql, MailHooksEntity.class, hookId); @@ -105,6 +158,7 @@ public MailHooksEntity selectOnKey(Integer hookId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM MAIL_HOOKS"; return executeQuerySingle(sql, Integer.class); @@ -134,8 +188,13 @@ public MailHooksEntity rawPhysicalInsert(MailHooksEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('MAIL_HOOKS_HOOK_ID_seq', (select max(HOOK_ID) from MAIL_HOOKS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(HOOK_ID) from MAIL_HOOKS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('MAIL_HOOKS_HOOK_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -175,9 +234,9 @@ public MailHooksEntity physicalInsert(MailHooksEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailHooksEntity insert(Integer user, MailHooksEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -231,7 +290,7 @@ public MailHooksEntity update(Integer user, MailHooksEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -308,7 +367,7 @@ public void delete(Integer user, Integer hookId) { MailHooksEntity db = selectOnKey(hookId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -357,7 +416,7 @@ public void activation(Integer user, Integer hookId) { MailHooksEntity db = physicalSelectOnKey(hookId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java index 88db5e38f..992198c5a 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenMailLocaleTemplatesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailLocaleTemplatesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailLocaleTemplatesEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int * @param templateId templateId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailLocaleTemplatesEntity physicalSelectOnKey(String key, String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, MailLocaleTemplatesEntity.class, key, templateId); @@ -71,8 +98,19 @@ public MailLocaleTemplatesEntity physicalSelectOnKey(String key, String template * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailLocaleTemplatesEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailLocaleTemplatesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param templateId templateId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailLocaleTemplatesEntity selectOnKey(String key, String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_key.sql"); return executeQuerySingle(sql, MailLocaleTemplatesEntity.class, key, templateId); @@ -108,6 +161,7 @@ public MailLocaleTemplatesEntity selectOnKey(String key, String templateId) { * @param key key * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKey(String key) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_col_key.sql"); return executeQueryList(sql, MailLocaleTemplatesEntity.class, key); @@ -117,6 +171,7 @@ public List selectOnKey(String key) { * @param templateId templateId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTemplateId(String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_template_id.sql"); return executeQueryList(sql, MailLocaleTemplatesEntity.class, templateId); @@ -126,6 +181,7 @@ public List selectOnTemplateId(String templateId) { * @param key key * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKey(String key) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_col_key.sql"); return executeQueryList(sql, MailLocaleTemplatesEntity.class, key); @@ -135,6 +191,7 @@ public List physicalSelectOnKey(String key) { * @param templateId templateId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnTemplateId(String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_template_id.sql"); return executeQueryList(sql, MailLocaleTemplatesEntity.class, templateId); @@ -143,6 +200,7 @@ public List physicalSelectOnTemplateId(String templat * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM MAIL_LOCALE_TEMPLATES"; return executeQuerySingle(sql, Integer.class); @@ -199,9 +257,9 @@ public MailLocaleTemplatesEntity physicalInsert(MailLocaleTemplatesEntity entity @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailLocaleTemplatesEntity insert(Integer user, MailLocaleTemplatesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -251,7 +309,7 @@ public MailLocaleTemplatesEntity update(Integer user, MailLocaleTemplatesEntity entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -330,7 +388,7 @@ public void delete(Integer user, String key, String templateId) { MailLocaleTemplatesEntity db = selectOnKey(key, templateId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -381,7 +439,7 @@ public void activation(Integer user, String key, String templateId) { MailLocaleTemplatesEntity db = physicalSelectOnKey(key, templateId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailPostsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailPostsDao.java index a5c5c8fc4..166ad9f62 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailPostsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailPostsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenMailPostsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPostsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPostsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param messageId messageId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailPostsEntity physicalSelectOnKey(String messageId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, MailPostsEntity.class, messageId); @@ -70,8 +97,19 @@ public MailPostsEntity physicalSelectOnKey(String messageId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPostsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPostsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param messageId messageId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailPostsEntity selectOnKey(String messageId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_on_key.sql"); return executeQuerySingle(sql, MailPostsEntity.class, messageId); @@ -105,6 +158,7 @@ public MailPostsEntity selectOnKey(String messageId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM MAIL_POSTS"; return executeQuerySingle(sql, Integer.class); @@ -161,9 +215,9 @@ public MailPostsEntity physicalInsert(MailPostsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailPostsEntity insert(Integer user, MailPostsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -213,7 +267,7 @@ public MailPostsEntity update(Integer user, MailPostsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -290,7 +344,7 @@ public void delete(Integer user, String messageId) { MailPostsEntity db = selectOnKey(messageId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -339,7 +393,7 @@ public void activation(Integer user, String messageId) { MailPostsEntity db = physicalSelectOnKey(messageId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java index 6f4dd9ddf..ed72f8dda 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenMailPropertiesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPropertiesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPropertiesEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offs * @param propertyKey propertyKey * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailPropertiesEntity physicalSelectOnKey(Integer hookId, String propertyKey) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, MailPropertiesEntity.class, hookId, propertyKey); @@ -71,8 +98,19 @@ public MailPropertiesEntity physicalSelectOnKey(Integer hookId, String propertyK * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPropertiesEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailPropertiesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param propertyKey propertyKey * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailPropertiesEntity selectOnKey(Integer hookId, String propertyKey) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_key.sql"); return executeQuerySingle(sql, MailPropertiesEntity.class, hookId, propertyKey); @@ -108,6 +161,7 @@ public MailPropertiesEntity selectOnKey(Integer hookId, String propertyKey) { * @param hookId hookId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnHookId(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_hook_id.sql"); return executeQueryList(sql, MailPropertiesEntity.class, hookId); @@ -117,6 +171,7 @@ public List selectOnHookId(Integer hookId) { * @param propertyKey propertyKey * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnPropertyKey(String propertyKey) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_property_key.sql"); return executeQueryList(sql, MailPropertiesEntity.class, propertyKey); @@ -126,6 +181,7 @@ public List selectOnPropertyKey(String propertyKey) { * @param hookId hookId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnHookId(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_hook_id.sql"); return executeQueryList(sql, MailPropertiesEntity.class, hookId); @@ -135,6 +191,7 @@ public List physicalSelectOnHookId(Integer hookId) { * @param propertyKey propertyKey * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnPropertyKey(String propertyKey) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_property_key.sql"); return executeQueryList(sql, MailPropertiesEntity.class, propertyKey); @@ -143,6 +200,7 @@ public List physicalSelectOnPropertyKey(String propertyKey * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM MAIL_PROPERTIES"; return executeQuerySingle(sql, Integer.class); @@ -197,9 +255,9 @@ public MailPropertiesEntity physicalInsert(MailPropertiesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailPropertiesEntity insert(Integer user, MailPropertiesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -248,7 +306,7 @@ public MailPropertiesEntity update(Integer user, MailPropertiesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -327,7 +385,7 @@ public void delete(Integer user, Integer hookId, String propertyKey) { MailPropertiesEntity db = selectOnKey(hookId, propertyKey); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -378,7 +436,7 @@ public void activation(Integer user, Integer hookId, String propertyKey) { MailPropertiesEntity db = physicalSelectOnKey(hookId, propertyKey); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailTemplatesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailTemplatesDao.java index 0698f0c0b..1df408ef1 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailTemplatesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailTemplatesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenMailTemplatesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailTemplatesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailTemplatesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param templateId templateId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailTemplatesEntity physicalSelectOnKey(String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, MailTemplatesEntity.class, templateId); @@ -70,8 +97,19 @@ public MailTemplatesEntity physicalSelectOnKey(String templateId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailTemplatesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, MailTemplatesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param templateId templateId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailTemplatesEntity selectOnKey(String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_on_key.sql"); return executeQuerySingle(sql, MailTemplatesEntity.class, templateId); @@ -105,6 +158,7 @@ public MailTemplatesEntity selectOnKey(String templateId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM MAIL_TEMPLATES"; return executeQuerySingle(sql, Integer.class); @@ -159,9 +213,9 @@ public MailTemplatesEntity physicalInsert(MailTemplatesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public MailTemplatesEntity insert(Integer user, MailTemplatesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -210,7 +264,7 @@ public MailTemplatesEntity update(Integer user, MailTemplatesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -287,7 +341,7 @@ public void delete(Integer user, String templateId) { MailTemplatesEntity db = selectOnKey(templateId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -336,7 +390,7 @@ public void activation(Integer user, String templateId) { MailTemplatesEntity db = physicalSelectOnKey(templateId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenNotificationStatusDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenNotificationStatusDao.java new file mode 100644 index 000000000..05a1f7b05 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenNotificationStatusDao.java @@ -0,0 +1,507 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.NotificationStatusEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * いいねの通知状態 + * this class is auto generate and not edit. + * if modify dao method, you can edit NotificationStatusDao. + */ +@DI(instance = Instance.Singleton) +public class GenNotificationStatusDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenNotificationStatusDao get() { + return Container.getComp(GenNotificationStatusDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, NotificationStatusEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, NotificationStatusEntity.class, limit, offset); + } + /** + * Select data on key. + * @param targetId targetId + * @param type type + * @param userId userId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity physicalSelectOnKey(Long targetId, Integer type, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, NotificationStatusEntity.class, targetId, type, userId); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, NotificationStatusEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, NotificationStatusEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param targetId targetId + * @param type type + * @param userId userId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity selectOnKey(Long targetId, Integer type, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_key.sql"); + return executeQuerySingle(sql, NotificationStatusEntity.class, targetId, type, userId); + } + /** + * Select data that not deleted on TARGET_ID column. + * @param targetId targetId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnTargetId(Long targetId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_target_id.sql"); + return executeQueryList(sql, NotificationStatusEntity.class, targetId); + } + /** + * Select data that not deleted on TYPE column. + * @param type type + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnType(Integer type) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_type.sql"); + return executeQueryList(sql, NotificationStatusEntity.class, type); + } + /** + * Select data that not deleted on USER_ID column. + * @param userId userId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnUserId(Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user_id.sql"); + return executeQueryList(sql, NotificationStatusEntity.class, userId); + } + /** + * Select data on TARGET_ID column. + * @param targetId targetId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnTargetId(Long targetId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_target_id.sql"); + return executeQueryList(sql, NotificationStatusEntity.class, targetId); + } + /** + * Select data on TYPE column. + * @param type type + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnType(Integer type) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_type.sql"); + return executeQueryList(sql, NotificationStatusEntity.class, type); + } + /** + * Select data on USER_ID column. + * @param userId userId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnUserId(Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user_id.sql"); + return executeQueryList(sql, NotificationStatusEntity.class, userId); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM NOTIFICATION_STATUS"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity rawPhysicalInsert(NotificationStatusEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_raw_insert.sql"); + executeUpdate(sql, + entity.getTargetId(), + entity.getType(), + entity.getUserId(), + entity.getStatus(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity physicalInsert(NotificationStatusEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_insert.sql"); + executeUpdate(sql, + entity.getTargetId(), + entity.getType(), + entity.getUserId(), + entity.getStatus(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity insert(Integer user, NotificationStatusEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity insert(NotificationStatusEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity physicalUpdate(NotificationStatusEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_update.sql"); + executeUpdate(sql, + entity.getStatus(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getTargetId(), + entity.getType(), + entity.getUserId()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity update(Integer user, NotificationStatusEntity entity) { + NotificationStatusEntity db = selectOnKey(entity.getTargetId(), entity.getType(), entity.getUserId()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity update(NotificationStatusEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity save(Integer user, NotificationStatusEntity entity) { + NotificationStatusEntity db = selectOnKey(entity.getTargetId(), entity.getType(), entity.getUserId()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public NotificationStatusEntity save(NotificationStatusEntity entity) { + NotificationStatusEntity db = selectOnKey(entity.getTargetId(), entity.getType(), entity.getUserId()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param targetId targetId + * @param type type + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Long targetId, Integer type, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_delete.sql"); + executeUpdate(sql, targetId, type, userId); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(NotificationStatusEntity entity) { + physicalDelete(entity.getTargetId(), entity.getType(), entity.getUserId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param targetId targetId + * @param type type + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Long targetId, Integer type, Integer userId) { + NotificationStatusEntity db = selectOnKey(targetId, type, userId); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param targetId targetId + * @param type type + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Long targetId, Integer type, Integer userId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, targetId, type, userId); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, NotificationStatusEntity entity) { + delete(user, entity.getTargetId(), entity.getType(), entity.getUserId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(NotificationStatusEntity entity) { + delete(entity.getTargetId(), entity.getType(), entity.getUserId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param targetId targetId + * @param type type + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Long targetId, Integer type, Integer userId) { + NotificationStatusEntity db = physicalSelectOnKey(targetId, type, userId); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param targetId targetId + * @param type type + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Long targetId, Integer type, Integer userId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, targetId, type, userId); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, NotificationStatusEntity entity) { + activation(user, entity.getTargetId(), entity.getType(), entity.getUserId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(NotificationStatusEntity entity) { + activation(entity.getTargetId(), entity.getType(), entity.getUserId()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java index d5fe87ffc..0f080acee 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenNotifyConfigsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyConfigsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyConfigsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyConfigsEntity physicalSelectOnKey(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, NotifyConfigsEntity.class, userId); @@ -70,8 +97,19 @@ public NotifyConfigsEntity physicalSelectOnKey(Integer userId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyConfigsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyConfigsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyConfigsEntity selectOnKey(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_on_key.sql"); return executeQuerySingle(sql, NotifyConfigsEntity.class, userId); @@ -105,6 +158,7 @@ public NotifyConfigsEntity selectOnKey(Integer userId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM NOTIFY_CONFIGS"; return executeQuerySingle(sql, Integer.class); @@ -175,9 +229,9 @@ public NotifyConfigsEntity physicalInsert(NotifyConfigsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyConfigsEntity insert(Integer user, NotifyConfigsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -234,7 +288,7 @@ public NotifyConfigsEntity update(Integer user, NotifyConfigsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -311,7 +365,7 @@ public void delete(Integer user, Integer userId) { NotifyConfigsEntity db = selectOnKey(userId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -360,7 +414,7 @@ public void activation(Integer user, Integer userId) { NotifyConfigsEntity db = physicalSelectOnKey(userId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java index 1e6a56304..9bda7a281 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenNotifyQueuesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyQueuesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyQueuesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset * @param hash hash * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyQueuesEntity physicalSelectOnKey(String hash) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, NotifyQueuesEntity.class, hash); @@ -70,8 +97,19 @@ public NotifyQueuesEntity physicalSelectOnKey(String hash) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyQueuesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, NotifyQueuesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param hash hash * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyQueuesEntity selectOnKey(String hash) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_on_key.sql"); return executeQuerySingle(sql, NotifyQueuesEntity.class, hash); @@ -105,6 +158,7 @@ public NotifyQueuesEntity selectOnKey(String hash) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM NOTIFY_QUEUES"; return executeQuerySingle(sql, Integer.class); @@ -159,9 +213,9 @@ public NotifyQueuesEntity physicalInsert(NotifyQueuesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public NotifyQueuesEntity insert(Integer user, NotifyQueuesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -210,7 +264,7 @@ public NotifyQueuesEntity update(Integer user, NotifyQueuesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -287,7 +341,7 @@ public void delete(Integer user, String hash) { NotifyQueuesEntity db = selectOnKey(hash); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -336,7 +390,7 @@ public void activation(Integer user, String hash) { NotifyQueuesEntity db = physicalSelectOnKey(hash); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenParticipantsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenParticipantsDao.java index 60718bebb..cec6fa6f3 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenParticipantsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenParticipantsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenParticipantsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ParticipantsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ParticipantsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offset * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ParticipantsEntity physicalSelectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, ParticipantsEntity.class, knowledgeId, userId); @@ -71,8 +98,19 @@ public ParticipantsEntity physicalSelectOnKey(Long knowledgeId, Integer userId) * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ParticipantsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ParticipantsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param userId userId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ParticipantsEntity selectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_on_key.sql"); return executeQuerySingle(sql, ParticipantsEntity.class, knowledgeId, userId); @@ -108,6 +161,7 @@ public ParticipantsEntity selectOnKey(Long knowledgeId, Integer userId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_on_knowledge_id.sql"); return executeQueryList(sql, ParticipantsEntity.class, knowledgeId); @@ -117,6 +171,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param userId userId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_on_user_id.sql"); return executeQueryList(sql, ParticipantsEntity.class, userId); @@ -126,6 +181,7 @@ public List selectOnUserId(Integer userId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, ParticipantsEntity.class, knowledgeId); @@ -135,6 +191,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) { * @param userId userId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_on_user_id.sql"); return executeQueryList(sql, ParticipantsEntity.class, userId); @@ -143,6 +200,7 @@ public List physicalSelectOnUserId(Integer userId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM PARTICIPANTS"; return executeQuerySingle(sql, Integer.class); @@ -197,9 +255,9 @@ public ParticipantsEntity physicalInsert(ParticipantsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ParticipantsEntity insert(Integer user, ParticipantsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -248,7 +306,7 @@ public ParticipantsEntity update(Integer user, ParticipantsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -327,7 +385,7 @@ public void delete(Integer user, Long knowledgeId, Integer userId) { ParticipantsEntity db = selectOnKey(knowledgeId, userId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -378,7 +436,7 @@ public void activation(Integer user, Long knowledgeId, Integer userId) { ParticipantsEntity db = physicalSelectOnKey(knowledgeId, userId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenPinsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenPinsDao.java index 948eeab27..86bd58d05 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenPinsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenPinsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenPinsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, PinsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, PinsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param no no * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public PinsEntity physicalSelectOnKey(Integer no) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, PinsEntity.class, no); @@ -70,8 +97,19 @@ public PinsEntity physicalSelectOnKey(Integer no) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, PinsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, PinsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param no no * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public PinsEntity selectOnKey(Integer no) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_on_key.sql"); return executeQuerySingle(sql, PinsEntity.class, no); @@ -105,6 +158,7 @@ public PinsEntity selectOnKey(Integer no) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM PINS"; return executeQuerySingle(sql, Integer.class); @@ -129,8 +183,13 @@ public PinsEntity rawPhysicalInsert(PinsEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('PINS_NO_seq', (select max(NO) from PINS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(NO) from PINS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('PINS_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -165,9 +224,9 @@ public PinsEntity physicalInsert(PinsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public PinsEntity insert(Integer user, PinsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -216,7 +275,7 @@ public PinsEntity update(Integer user, PinsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -293,7 +352,7 @@ public void delete(Integer user, Integer no) { PinsEntity db = selectOnKey(no); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -342,7 +401,7 @@ public void activation(Integer user, Integer no) { PinsEntity db = physicalSelectOnKey(no); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenPointKnowledgeHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenPointKnowledgeHistoriesDao.java new file mode 100644 index 000000000..11db71c64 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenPointKnowledgeHistoriesDao.java @@ -0,0 +1,489 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.PointKnowledgeHistoriesEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * ナレッジのポイント獲得履歴 + * this class is auto generate and not edit. + * if modify dao method, you can edit PointKnowledgeHistoriesDao. + */ +@DI(instance = Instance.Singleton) +public class GenPointKnowledgeHistoriesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenPointKnowledgeHistoriesDao get() { + return Container.getComp(GenPointKnowledgeHistoriesDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class, limit, offset); + } + /** + * Select data on key. + * @param historyNo historyNo + * @param knowledgeId knowledgeId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity physicalSelectOnKey(Long historyNo, Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, PointKnowledgeHistoriesEntity.class, historyNo, knowledgeId); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param historyNo historyNo + * @param knowledgeId knowledgeId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity selectOnKey(Long historyNo, Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_key.sql"); + return executeQuerySingle(sql, PointKnowledgeHistoriesEntity.class, historyNo, knowledgeId); + } + /** + * Select data that not deleted on HISTORY_NO column. + * @param historyNo historyNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnHistoryNo(Long historyNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_history_no.sql"); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class, historyNo); + } + /** + * Select data that not deleted on KNOWLEDGE_ID column. + * @param knowledgeId knowledgeId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnKnowledgeId(Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_knowledge_id.sql"); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class, knowledgeId); + } + /** + * Select data on HISTORY_NO column. + * @param historyNo historyNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnHistoryNo(Long historyNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_history_no.sql"); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class, historyNo); + } + /** + * Select data on KNOWLEDGE_ID column. + * @param knowledgeId knowledgeId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnKnowledgeId(Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_knowledge_id.sql"); + return executeQueryList(sql, PointKnowledgeHistoriesEntity.class, knowledgeId); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM POINT_KNOWLEDGE_HISTORIES"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity rawPhysicalInsert(PointKnowledgeHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo(), + entity.getKnowledgeId(), + entity.getActivityNo(), + entity.getType(), + entity.getPoint(), + entity.getBeforeTotal(), + entity.getTotal(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity physicalInsert(PointKnowledgeHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo(), + entity.getKnowledgeId(), + entity.getActivityNo(), + entity.getType(), + entity.getPoint(), + entity.getBeforeTotal(), + entity.getTotal(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity insert(Integer user, PointKnowledgeHistoriesEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity insert(PointKnowledgeHistoriesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity physicalUpdate(PointKnowledgeHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_update.sql"); + executeUpdate(sql, + entity.getActivityNo(), + entity.getType(), + entity.getPoint(), + entity.getBeforeTotal(), + entity.getTotal(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getHistoryNo(), + entity.getKnowledgeId()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity update(Integer user, PointKnowledgeHistoriesEntity entity) { + PointKnowledgeHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getKnowledgeId()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity update(PointKnowledgeHistoriesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity save(Integer user, PointKnowledgeHistoriesEntity entity) { + PointKnowledgeHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getKnowledgeId()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointKnowledgeHistoriesEntity save(PointKnowledgeHistoriesEntity entity) { + PointKnowledgeHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getKnowledgeId()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param historyNo historyNo + * @param knowledgeId knowledgeId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Long historyNo, Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_delete.sql"); + executeUpdate(sql, historyNo, knowledgeId); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(PointKnowledgeHistoriesEntity entity) { + physicalDelete(entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param historyNo historyNo + * @param knowledgeId knowledgeId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Long historyNo, Long knowledgeId) { + PointKnowledgeHistoriesEntity db = selectOnKey(historyNo, knowledgeId); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param historyNo historyNo + * @param knowledgeId knowledgeId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Long historyNo, Long knowledgeId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, historyNo, knowledgeId); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, PointKnowledgeHistoriesEntity entity) { + delete(user, entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(PointKnowledgeHistoriesEntity entity) { + delete(entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param historyNo historyNo + * @param knowledgeId knowledgeId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Long historyNo, Long knowledgeId) { + PointKnowledgeHistoriesEntity db = physicalSelectOnKey(historyNo, knowledgeId); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param historyNo historyNo + * @param knowledgeId knowledgeId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Long historyNo, Long knowledgeId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, historyNo, knowledgeId); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, PointKnowledgeHistoriesEntity entity) { + activation(user, entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(PointKnowledgeHistoriesEntity entity) { + activation(entity.getHistoryNo(), entity.getKnowledgeId()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenPointUserHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenPointUserHistoriesDao.java new file mode 100644 index 000000000..8e8b0ed9d --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenPointUserHistoriesDao.java @@ -0,0 +1,489 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.PointUserHistoriesEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * ユーザのポイント獲得履歴 + * this class is auto generate and not edit. + * if modify dao method, you can edit PointUserHistoriesDao. + */ +@DI(instance = Instance.Singleton) +public class GenPointUserHistoriesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenPointUserHistoriesDao get() { + return Container.getComp(GenPointUserHistoriesDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointUserHistoriesEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointUserHistoriesEntity.class, limit, offset); + } + /** + * Select data on key. + * @param historyNo historyNo + * @param userId userId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity physicalSelectOnKey(Long historyNo, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, PointUserHistoriesEntity.class, historyNo, userId); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointUserHistoriesEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, PointUserHistoriesEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param historyNo historyNo + * @param userId userId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity selectOnKey(Long historyNo, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_key.sql"); + return executeQuerySingle(sql, PointUserHistoriesEntity.class, historyNo, userId); + } + /** + * Select data that not deleted on HISTORY_NO column. + * @param historyNo historyNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnHistoryNo(Long historyNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_history_no.sql"); + return executeQueryList(sql, PointUserHistoriesEntity.class, historyNo); + } + /** + * Select data that not deleted on USER_ID column. + * @param userId userId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnUserId(Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_user_id.sql"); + return executeQueryList(sql, PointUserHistoriesEntity.class, userId); + } + /** + * Select data on HISTORY_NO column. + * @param historyNo historyNo + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnHistoryNo(Long historyNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_history_no.sql"); + return executeQueryList(sql, PointUserHistoriesEntity.class, historyNo); + } + /** + * Select data on USER_ID column. + * @param userId userId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnUserId(Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_user_id.sql"); + return executeQueryList(sql, PointUserHistoriesEntity.class, userId); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM POINT_USER_HISTORIES"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity rawPhysicalInsert(PointUserHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo(), + entity.getUserId(), + entity.getActivityNo(), + entity.getType(), + entity.getPoint(), + entity.getBeforeTotal(), + entity.getTotal(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity physicalInsert(PointUserHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo(), + entity.getUserId(), + entity.getActivityNo(), + entity.getType(), + entity.getPoint(), + entity.getBeforeTotal(), + entity.getTotal(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity insert(Integer user, PointUserHistoriesEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity insert(PointUserHistoriesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity physicalUpdate(PointUserHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_update.sql"); + executeUpdate(sql, + entity.getActivityNo(), + entity.getType(), + entity.getPoint(), + entity.getBeforeTotal(), + entity.getTotal(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getHistoryNo(), + entity.getUserId()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity update(Integer user, PointUserHistoriesEntity entity) { + PointUserHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getUserId()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity update(PointUserHistoriesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity save(Integer user, PointUserHistoriesEntity entity) { + PointUserHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getUserId()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public PointUserHistoriesEntity save(PointUserHistoriesEntity entity) { + PointUserHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getUserId()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param historyNo historyNo + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Long historyNo, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_delete.sql"); + executeUpdate(sql, historyNo, userId); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(PointUserHistoriesEntity entity) { + physicalDelete(entity.getHistoryNo(), entity.getUserId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param historyNo historyNo + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Long historyNo, Integer userId) { + PointUserHistoriesEntity db = selectOnKey(historyNo, userId); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param historyNo historyNo + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Long historyNo, Integer userId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, historyNo, userId); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, PointUserHistoriesEntity entity) { + delete(user, entity.getHistoryNo(), entity.getUserId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(PointUserHistoriesEntity entity) { + delete(entity.getHistoryNo(), entity.getUserId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param historyNo historyNo + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Long historyNo, Integer userId) { + PointUserHistoriesEntity db = physicalSelectOnKey(historyNo, userId); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param historyNo historyNo + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Long historyNo, Integer userId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, historyNo, userId); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, PointUserHistoriesEntity entity) { + activation(user, entity.getHistoryNo(), entity.getUserId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(PointUserHistoriesEntity entity) { + activation(entity.getHistoryNo(), entity.getUserId()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenServiceConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenServiceConfigsDao.java index 8ff4d6cc2..5851e56d2 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenServiceConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenServiceConfigsDao.java @@ -13,8 +13,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -44,8 +46,19 @@ public static GenServiceConfigsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceConfigsEntity.class); } /** @@ -54,8 +67,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceConfigsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offs * @param serviceName serviceName * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ServiceConfigsEntity physicalSelectOnKey(String serviceName) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, ServiceConfigsEntity.class, serviceName); @@ -71,8 +98,19 @@ public ServiceConfigsEntity physicalSelectOnKey(String serviceName) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceConfigsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceConfigsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -98,6 +150,7 @@ public Integer selectCountAll() { * @param serviceName serviceName * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ServiceConfigsEntity selectOnKey(String serviceName) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_on_key.sql"); return executeQuerySingle(sql, ServiceConfigsEntity.class, serviceName); @@ -106,6 +159,7 @@ public ServiceConfigsEntity selectOnKey(String serviceName) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SERVICE_CONFIGS"; return executeQuerySingle(sql, Integer.class); @@ -162,9 +216,9 @@ public ServiceConfigsEntity physicalInsert(ServiceConfigsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ServiceConfigsEntity insert(Integer user, ServiceConfigsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -214,7 +268,7 @@ public ServiceConfigsEntity update(Integer user, ServiceConfigsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -291,7 +345,7 @@ public void delete(Integer user, String serviceName) { ServiceConfigsEntity db = selectOnKey(serviceName); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -340,7 +394,7 @@ public void activation(Integer user, String serviceName) { ServiceConfigsEntity db = physicalSelectOnKey(serviceName); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenServiceLocaleConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenServiceLocaleConfigsDao.java index 3f8aace86..5d3e86dfa 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenServiceLocaleConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenServiceLocaleConfigsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenServiceLocaleConfigsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceLocaleConfigsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceLocaleConfigsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, in * @param serviceName serviceName * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ServiceLocaleConfigsEntity physicalSelectOnKey(String localeKey, String serviceName) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, ServiceLocaleConfigsEntity.class, localeKey, serviceName); @@ -71,8 +98,19 @@ public ServiceLocaleConfigsEntity physicalSelectOnKey(String localeKey, String s * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceLocaleConfigsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ServiceLocaleConfigsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param serviceName serviceName * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ServiceLocaleConfigsEntity selectOnKey(String localeKey, String serviceName) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_on_key.sql"); return executeQuerySingle(sql, ServiceLocaleConfigsEntity.class, localeKey, serviceName); @@ -108,6 +161,7 @@ public ServiceLocaleConfigsEntity selectOnKey(String localeKey, String serviceNa * @param localeKey localeKey * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnLocaleKey(String localeKey) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_on_locale_key.sql"); return executeQueryList(sql, ServiceLocaleConfigsEntity.class, localeKey); @@ -117,6 +171,7 @@ public List selectOnLocaleKey(String localeKey) { * @param serviceName serviceName * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnServiceName(String serviceName) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_on_service_name.sql"); return executeQueryList(sql, ServiceLocaleConfigsEntity.class, serviceName); @@ -126,6 +181,7 @@ public List selectOnServiceName(String serviceName) * @param localeKey localeKey * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnLocaleKey(String localeKey) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_on_locale_key.sql"); return executeQueryList(sql, ServiceLocaleConfigsEntity.class, localeKey); @@ -135,6 +191,7 @@ public List physicalSelectOnLocaleKey(String localeK * @param serviceName serviceName * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnServiceName(String serviceName) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_on_service_name.sql"); return executeQueryList(sql, ServiceLocaleConfigsEntity.class, serviceName); @@ -143,6 +200,7 @@ public List physicalSelectOnServiceName(String servi * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SERVICE_LOCALE_CONFIGS"; return executeQuerySingle(sql, Integer.class); @@ -197,9 +255,9 @@ public ServiceLocaleConfigsEntity physicalInsert(ServiceLocaleConfigsEntity enti @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ServiceLocaleConfigsEntity insert(Integer user, ServiceLocaleConfigsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -248,7 +306,7 @@ public ServiceLocaleConfigsEntity update(Integer user, ServiceLocaleConfigsEntit entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -327,7 +385,7 @@ public void delete(Integer user, String localeKey, String serviceName) { ServiceLocaleConfigsEntity db = selectOnKey(localeKey, serviceName); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -378,7 +436,7 @@ public void activation(Integer user, String localeKey, String serviceName) { ServiceLocaleConfigsEntity db = physicalSelectOnKey(localeKey, serviceName); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenStockKnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenStockKnowledgesDao.java index 80c53a332..04c0129e8 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenStockKnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenStockKnowledgesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenStockKnowledgesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StockKnowledgesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StockKnowledgesEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int off * @param stockId stockId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public StockKnowledgesEntity physicalSelectOnKey(Long knowledgeId, Long stockId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, StockKnowledgesEntity.class, knowledgeId, stockId); @@ -71,8 +98,19 @@ public StockKnowledgesEntity physicalSelectOnKey(Long knowledgeId, Long stockId) * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StockKnowledgesEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StockKnowledgesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param stockId stockId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public StockKnowledgesEntity selectOnKey(Long knowledgeId, Long stockId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_on_key.sql"); return executeQuerySingle(sql, StockKnowledgesEntity.class, knowledgeId, stockId); @@ -108,6 +161,7 @@ public StockKnowledgesEntity selectOnKey(Long knowledgeId, Long stockId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_on_knowledge_id.sql"); return executeQueryList(sql, StockKnowledgesEntity.class, knowledgeId); @@ -117,6 +171,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param stockId stockId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnStockId(Long stockId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_on_stock_id.sql"); return executeQueryList(sql, StockKnowledgesEntity.class, stockId); @@ -126,6 +181,7 @@ public List selectOnStockId(Long stockId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, StockKnowledgesEntity.class, knowledgeId); @@ -135,6 +191,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) * @param stockId stockId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnStockId(Long stockId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_on_stock_id.sql"); return executeQueryList(sql, StockKnowledgesEntity.class, stockId); @@ -143,6 +200,7 @@ public List physicalSelectOnStockId(Long stockId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM STOCK_KNOWLEDGES"; return executeQuerySingle(sql, Integer.class); @@ -197,9 +255,9 @@ public StockKnowledgesEntity physicalInsert(StockKnowledgesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public StockKnowledgesEntity insert(Integer user, StockKnowledgesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -248,7 +306,7 @@ public StockKnowledgesEntity update(Integer user, StockKnowledgesEntity entity) entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -327,7 +385,7 @@ public void delete(Integer user, Long knowledgeId, Long stockId) { StockKnowledgesEntity db = selectOnKey(knowledgeId, stockId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -378,7 +436,7 @@ public void activation(Integer user, Long knowledgeId, Long stockId) { StockKnowledgesEntity db = physicalSelectOnKey(knowledgeId, stockId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java index f63916e62..e6197a988 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenStocksDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StocksEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StocksEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param stockId stockId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public StocksEntity physicalSelectOnKey(Long stockId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_on_key.sql"); return executeQuerySingle(sql, StocksEntity.class, stockId); @@ -70,8 +97,19 @@ public StocksEntity physicalSelectOnKey(Long stockId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StocksEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, StocksEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param stockId stockId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public StocksEntity selectOnKey(Long stockId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_on_key.sql"); return executeQuerySingle(sql, StocksEntity.class, stockId); @@ -105,6 +158,7 @@ public StocksEntity selectOnKey(Long stockId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM STOCKS"; return executeQuerySingle(sql, Integer.class); @@ -130,8 +184,13 @@ public StocksEntity rawPhysicalInsert(StocksEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('STOCKS_STOCK_ID_seq', (select max(STOCK_ID) from STOCKS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(STOCK_ID) from STOCKS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('STOCKS_STOCK_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -167,9 +226,9 @@ public StocksEntity physicalInsert(StocksEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public StocksEntity insert(Integer user, StocksEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -219,7 +278,7 @@ public StocksEntity update(Integer user, StocksEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -296,7 +355,7 @@ public void delete(Integer user, Long stockId) { StocksEntity db = selectOnKey(stockId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -345,7 +404,7 @@ public void activation(Integer user, Long stockId) { StocksEntity db = physicalSelectOnKey(stockId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyAnswersDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyAnswersDao.java index adddcdbbd..1c5427a50 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyAnswersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyAnswersDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenSurveyAnswersDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyAnswersEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyAnswersEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyAnswersEntity physicalSelectOnKey(Integer answerId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_on_key.sql"); return executeQuerySingle(sql, SurveyAnswersEntity.class, answerId, knowledgeId); @@ -71,8 +98,19 @@ public SurveyAnswersEntity physicalSelectOnKey(Integer answerId, Long knowledgeI * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyAnswersEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyAnswersEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyAnswersEntity selectOnKey(Integer answerId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_on_key.sql"); return executeQuerySingle(sql, SurveyAnswersEntity.class, answerId, knowledgeId); @@ -108,6 +161,7 @@ public SurveyAnswersEntity selectOnKey(Integer answerId, Long knowledgeId) { * @param answerId answerId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnAnswerId(Integer answerId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_on_answer_id.sql"); return executeQueryList(sql, SurveyAnswersEntity.class, answerId); @@ -117,6 +171,7 @@ public List selectOnAnswerId(Integer answerId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyAnswersEntity.class, knowledgeId); @@ -126,6 +181,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param answerId answerId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnAnswerId(Integer answerId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_on_answer_id.sql"); return executeQueryList(sql, SurveyAnswersEntity.class, answerId); @@ -135,6 +191,7 @@ public List physicalSelectOnAnswerId(Integer answerId) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyAnswersEntity.class, knowledgeId); @@ -143,6 +200,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SURVEY_ANSWERS"; return executeQuerySingle(sql, Integer.class); @@ -195,9 +253,9 @@ public SurveyAnswersEntity physicalInsert(SurveyAnswersEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyAnswersEntity insert(Integer user, SurveyAnswersEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -245,7 +303,7 @@ public SurveyAnswersEntity update(Integer user, SurveyAnswersEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -324,7 +382,7 @@ public void delete(Integer user, Integer answerId, Long knowledgeId) { SurveyAnswersEntity db = selectOnKey(answerId, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -375,7 +433,7 @@ public void activation(Integer user, Integer answerId, Long knowledgeId) { SurveyAnswersEntity db = physicalSelectOnKey(answerId, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyChoicesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyChoicesDao.java index 87e425952..5da7a466d 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyChoicesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyChoicesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenSurveyChoicesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyChoicesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyChoicesEntity.class, limit, offset); } /** @@ -64,6 +90,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyChoicesEntity physicalSelectOnKey(Integer choiceNo, Integer itemNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, SurveyChoicesEntity.class, choiceNo, itemNo, knowledgeId); @@ -72,8 +99,19 @@ public SurveyChoicesEntity physicalSelectOnKey(Integer choiceNo, Integer itemNo, * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyChoicesEntity.class); } /** @@ -82,14 +120,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyChoicesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -101,6 +153,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyChoicesEntity selectOnKey(Integer choiceNo, Integer itemNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_on_key.sql"); return executeQuerySingle(sql, SurveyChoicesEntity.class, choiceNo, itemNo, knowledgeId); @@ -110,6 +163,7 @@ public SurveyChoicesEntity selectOnKey(Integer choiceNo, Integer itemNo, Long kn * @param choiceNo choiceNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnChoiceNo(Integer choiceNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_on_choice_no.sql"); return executeQueryList(sql, SurveyChoicesEntity.class, choiceNo); @@ -119,6 +173,7 @@ public List selectOnChoiceNo(Integer choiceNo) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_on_item_no.sql"); return executeQueryList(sql, SurveyChoicesEntity.class, itemNo); @@ -128,6 +183,7 @@ public List selectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyChoicesEntity.class, knowledgeId); @@ -137,6 +193,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param choiceNo choiceNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnChoiceNo(Integer choiceNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_on_choice_no.sql"); return executeQueryList(sql, SurveyChoicesEntity.class, choiceNo); @@ -146,6 +203,7 @@ public List physicalSelectOnChoiceNo(Integer choiceNo) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_on_item_no.sql"); return executeQueryList(sql, SurveyChoicesEntity.class, itemNo); @@ -155,6 +213,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyChoicesEntity.class, knowledgeId); @@ -163,6 +222,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SURVEY_CHOICES"; return executeQuerySingle(sql, Integer.class); @@ -221,9 +281,9 @@ public SurveyChoicesEntity physicalInsert(SurveyChoicesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyChoicesEntity insert(Integer user, SurveyChoicesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -274,7 +334,7 @@ public SurveyChoicesEntity update(Integer user, SurveyChoicesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -355,7 +415,7 @@ public void delete(Integer user, Integer choiceNo, Integer itemNo, Long knowledg SurveyChoicesEntity db = selectOnKey(choiceNo, itemNo, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -408,7 +468,7 @@ public void activation(Integer user, Integer choiceNo, Integer itemNo, Long know SurveyChoicesEntity db = physicalSelectOnKey(choiceNo, itemNo, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemAnswersDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemAnswersDao.java index f56e4ffc6..10fc6310c 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemAnswersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemAnswersDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenSurveyItemAnswersDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemAnswersEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemAnswersEntity.class, limit, offset); } /** @@ -64,6 +90,7 @@ public List physicalSelectAllWithPager(int limit, int o * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyItemAnswersEntity physicalSelectOnKey(Integer answerId, Integer itemNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_on_key.sql"); return executeQuerySingle(sql, SurveyItemAnswersEntity.class, answerId, itemNo, knowledgeId); @@ -72,8 +99,19 @@ public SurveyItemAnswersEntity physicalSelectOnKey(Integer answerId, Integer ite * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemAnswersEntity.class); } /** @@ -82,14 +120,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemAnswersEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -101,6 +153,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyItemAnswersEntity selectOnKey(Integer answerId, Integer itemNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_on_key.sql"); return executeQuerySingle(sql, SurveyItemAnswersEntity.class, answerId, itemNo, knowledgeId); @@ -110,6 +163,7 @@ public SurveyItemAnswersEntity selectOnKey(Integer answerId, Integer itemNo, Lon * @param answerId answerId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnAnswerId(Integer answerId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_on_answer_id.sql"); return executeQueryList(sql, SurveyItemAnswersEntity.class, answerId); @@ -119,6 +173,7 @@ public List selectOnAnswerId(Integer answerId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_on_item_no.sql"); return executeQueryList(sql, SurveyItemAnswersEntity.class, itemNo); @@ -128,6 +183,7 @@ public List selectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyItemAnswersEntity.class, knowledgeId); @@ -137,6 +193,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param answerId answerId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnAnswerId(Integer answerId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_on_answer_id.sql"); return executeQueryList(sql, SurveyItemAnswersEntity.class, answerId); @@ -146,6 +203,7 @@ public List physicalSelectOnAnswerId(Integer answerId) * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_on_item_no.sql"); return executeQueryList(sql, SurveyItemAnswersEntity.class, itemNo); @@ -155,6 +213,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyItemAnswersEntity.class, knowledgeId); @@ -163,6 +222,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeI * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SURVEY_ITEM_ANSWERS"; return executeQuerySingle(sql, Integer.class); @@ -219,9 +279,9 @@ public SurveyItemAnswersEntity physicalInsert(SurveyItemAnswersEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyItemAnswersEntity insert(Integer user, SurveyItemAnswersEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -271,7 +331,7 @@ public SurveyItemAnswersEntity update(Integer user, SurveyItemAnswersEntity enti entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -352,7 +412,7 @@ public void delete(Integer user, Integer answerId, Integer itemNo, Long knowledg SurveyItemAnswersEntity db = selectOnKey(answerId, itemNo, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -405,7 +465,7 @@ public void activation(Integer user, Integer answerId, Integer itemNo, Long know SurveyItemAnswersEntity db = physicalSelectOnKey(answerId, itemNo, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemsDao.java index c1c1f8160..21674d54d 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveyItemsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenSurveyItemsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offset) * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyItemsEntity physicalSelectOnKey(Integer itemNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, SurveyItemsEntity.class, itemNo, knowledgeId); @@ -71,8 +98,19 @@ public SurveyItemsEntity physicalSelectOnKey(Integer itemNo, Long knowledgeId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveyItemsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyItemsEntity selectOnKey(Integer itemNo, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_on_key.sql"); return executeQuerySingle(sql, SurveyItemsEntity.class, itemNo, knowledgeId); @@ -108,6 +161,7 @@ public SurveyItemsEntity selectOnKey(Integer itemNo, Long knowledgeId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_on_item_no.sql"); return executeQueryList(sql, SurveyItemsEntity.class, itemNo); @@ -117,6 +171,7 @@ public List selectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyItemsEntity.class, knowledgeId); @@ -126,6 +181,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_on_item_no.sql"); return executeQueryList(sql, SurveyItemsEntity.class, itemNo); @@ -135,6 +191,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param knowledgeId knowledgeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_on_knowledge_id.sql"); return executeQueryList(sql, SurveyItemsEntity.class, knowledgeId); @@ -143,6 +200,7 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SURVEY_ITEMS"; return executeQuerySingle(sql, Integer.class); @@ -201,9 +259,9 @@ public SurveyItemsEntity physicalInsert(SurveyItemsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveyItemsEntity insert(Integer user, SurveyItemsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -254,7 +312,7 @@ public SurveyItemsEntity update(Integer user, SurveyItemsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -333,7 +391,7 @@ public void delete(Integer user, Integer itemNo, Long knowledgeId) { SurveyItemsEntity db = selectOnKey(itemNo, knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -384,7 +442,7 @@ public void activation(Integer user, Integer itemNo, Long knowledgeId) { SurveyItemsEntity db = physicalSelectOnKey(itemNo, knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveysDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveysDao.java index e46f71947..43e9727c1 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenSurveysDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenSurveysDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenSurveysDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveysEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveysEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveysEntity physicalSelectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_on_key.sql"); return executeQuerySingle(sql, SurveysEntity.class, knowledgeId); @@ -70,8 +97,19 @@ public SurveysEntity physicalSelectOnKey(Long knowledgeId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveysEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, SurveysEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param knowledgeId knowledgeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveysEntity selectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_key.sql"); return executeQuerySingle(sql, SurveysEntity.class, knowledgeId); @@ -105,6 +158,7 @@ public SurveysEntity selectOnKey(Long knowledgeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM SURVEYS"; return executeQuerySingle(sql, Integer.class); @@ -159,9 +213,9 @@ public SurveysEntity physicalInsert(SurveysEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public SurveysEntity insert(Integer user, SurveysEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -210,7 +264,7 @@ public SurveysEntity update(Integer user, SurveysEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -287,7 +341,7 @@ public void delete(Integer user, Long knowledgeId) { SurveysEntity db = selectOnKey(knowledgeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -336,7 +390,7 @@ public void activation(Integer user, Long knowledgeId) { SurveysEntity db = physicalSelectOnKey(knowledgeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java index ef6e4230b..3d0a4ace1 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenTagsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TagsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TagsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param tagId tagId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TagsEntity physicalSelectOnKey(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, TagsEntity.class, tagId); @@ -70,8 +97,19 @@ public TagsEntity physicalSelectOnKey(Integer tagId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TagsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TagsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param tagId tagId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TagsEntity selectOnKey(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_on_key.sql"); return executeQuerySingle(sql, TagsEntity.class, tagId); @@ -105,6 +158,7 @@ public TagsEntity selectOnKey(Integer tagId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM TAGS"; return executeQuerySingle(sql, Integer.class); @@ -128,8 +182,13 @@ public TagsEntity rawPhysicalInsert(TagsEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('TAGS_TAG_ID_seq', (select max(TAG_ID) from TAGS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(TAG_ID) from TAGS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('TAGS_TAG_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -163,9 +222,9 @@ public TagsEntity physicalInsert(TagsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TagsEntity insert(Integer user, TagsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -213,7 +272,7 @@ public TagsEntity update(Integer user, TagsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -290,7 +349,7 @@ public void delete(Integer user, Integer tagId) { TagsEntity db = selectOnKey(tagId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -339,7 +398,7 @@ public void activation(Integer user, Integer tagId) { TagsEntity db = physicalSelectOnKey(tagId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateItemsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateItemsDao.java index 0fa446953..4e2a0a3e3 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateItemsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateItemsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenTemplateItemsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateItemsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateItemsEntity.class, limit, offset); } /** @@ -63,6 +89,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateItemsEntity physicalSelectOnKey(Integer itemNo, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, TemplateItemsEntity.class, itemNo, typeId); @@ -71,8 +98,19 @@ public TemplateItemsEntity physicalSelectOnKey(Integer itemNo, Integer typeId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateItemsEntity.class); } /** @@ -81,14 +119,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateItemsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -99,6 +151,7 @@ public Integer selectCountAll() { * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateItemsEntity selectOnKey(Integer itemNo, Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_on_key.sql"); return executeQuerySingle(sql, TemplateItemsEntity.class, itemNo, typeId); @@ -108,6 +161,7 @@ public TemplateItemsEntity selectOnKey(Integer itemNo, Integer typeId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_on_item_no.sql"); return executeQueryList(sql, TemplateItemsEntity.class, itemNo); @@ -117,6 +171,7 @@ public List selectOnItemNo(Integer itemNo) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_on_type_id.sql"); return executeQueryList(sql, TemplateItemsEntity.class, typeId); @@ -126,6 +181,7 @@ public List selectOnTypeId(Integer typeId) { * @param itemNo itemNo * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnItemNo(Integer itemNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_on_item_no.sql"); return executeQueryList(sql, TemplateItemsEntity.class, itemNo); @@ -135,6 +191,7 @@ public List physicalSelectOnItemNo(Integer itemNo) { * @param typeId typeId * @return list */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectOnTypeId(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_on_type_id.sql"); return executeQueryList(sql, TemplateItemsEntity.class, typeId); @@ -143,6 +200,7 @@ public List physicalSelectOnTypeId(Integer typeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM TEMPLATE_ITEMS"; return executeQuerySingle(sql, Integer.class); @@ -162,6 +220,7 @@ public TemplateItemsEntity rawPhysicalInsert(TemplateItemsEntity entity) { entity.getItemName(), entity.getItemType(), entity.getDescription(), + entity.getInitialValue(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -184,6 +243,7 @@ public TemplateItemsEntity physicalInsert(TemplateItemsEntity entity) { entity.getItemName(), entity.getItemType(), entity.getDescription(), + entity.getInitialValue(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -201,9 +261,9 @@ public TemplateItemsEntity physicalInsert(TemplateItemsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateItemsEntity insert(Integer user, TemplateItemsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -231,6 +291,7 @@ public TemplateItemsEntity physicalUpdate(TemplateItemsEntity entity) { entity.getItemName(), entity.getItemType(), entity.getDescription(), + entity.getInitialValue(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -254,7 +315,7 @@ public TemplateItemsEntity update(Integer user, TemplateItemsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -333,7 +394,7 @@ public void delete(Integer user, Integer itemNo, Integer typeId) { TemplateItemsEntity db = selectOnKey(itemNo, typeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -384,7 +445,7 @@ public void activation(Integer user, Integer itemNo, Integer typeId) { TemplateItemsEntity db = physicalSelectOnKey(itemNo, typeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateMastersDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateMastersDao.java index 3f00ac3d6..3c877044d 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateMastersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenTemplateMastersDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenTemplateMastersDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateMastersEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateMastersEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int off * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateMastersEntity physicalSelectOnKey(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_on_key.sql"); return executeQuerySingle(sql, TemplateMastersEntity.class, typeId); @@ -70,8 +97,19 @@ public TemplateMastersEntity physicalSelectOnKey(Integer typeId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateMastersEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TemplateMastersEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param typeId typeId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateMastersEntity selectOnKey(Integer typeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_on_key.sql"); return executeQuerySingle(sql, TemplateMastersEntity.class, typeId); @@ -105,6 +158,7 @@ public TemplateMastersEntity selectOnKey(Integer typeId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM TEMPLATE_MASTERS"; return executeQuerySingle(sql, Integer.class); @@ -123,6 +177,7 @@ public TemplateMastersEntity rawPhysicalInsert(TemplateMastersEntity entity) { entity.getTypeName(), entity.getTypeIcon(), entity.getDescription(), + entity.getInitialValue(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -130,8 +185,13 @@ public TemplateMastersEntity rawPhysicalInsert(TemplateMastersEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('TEMPLATE_MASTERS_TYPE_ID_seq', (select max(TYPE_ID) from TEMPLATE_MASTERS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(TYPE_ID) from TEMPLATE_MASTERS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('TEMPLATE_MASTERS_TYPE_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -149,6 +209,7 @@ public TemplateMastersEntity physicalInsert(TemplateMastersEntity entity) { entity.getTypeName(), entity.getTypeIcon(), entity.getDescription(), + entity.getInitialValue(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -167,9 +228,9 @@ public TemplateMastersEntity physicalInsert(TemplateMastersEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TemplateMastersEntity insert(Integer user, TemplateMastersEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -197,6 +258,7 @@ public TemplateMastersEntity physicalUpdate(TemplateMastersEntity entity) { entity.getTypeName(), entity.getTypeIcon(), entity.getDescription(), + entity.getInitialValue(), entity.getInsertUser(), entity.getInsertDatetime(), entity.getUpdateUser(), @@ -219,7 +281,7 @@ public TemplateMastersEntity update(Integer user, TemplateMastersEntity entity) entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -296,7 +358,7 @@ public void delete(Integer user, Integer typeId) { TemplateMastersEntity db = selectOnKey(typeId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -345,7 +407,7 @@ public void activation(Integer user, Integer typeId) { TemplateMastersEntity db = physicalSelectOnKey(typeId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java index 81d688106..de827e4b8 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenTokensDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TokensEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TokensEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param token token * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TokensEntity physicalSelectOnKey(String token) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_on_key.sql"); return executeQuerySingle(sql, TokensEntity.class, token); @@ -70,8 +97,19 @@ public TokensEntity physicalSelectOnKey(String token) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TokensEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, TokensEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param token token * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TokensEntity selectOnKey(String token) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_on_key.sql"); return executeQuerySingle(sql, TokensEntity.class, token); @@ -105,6 +158,7 @@ public TokensEntity selectOnKey(String token) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM TOKENS"; return executeQuerySingle(sql, Integer.class); @@ -159,9 +213,9 @@ public TokensEntity physicalInsert(TokensEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public TokensEntity insert(Integer user, TokensEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -210,7 +264,7 @@ public TokensEntity update(Integer user, TokensEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -287,7 +341,7 @@ public void delete(Integer user, String token) { TokensEntity db = selectOnKey(token); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -336,7 +390,7 @@ public void activation(Integer user, String token) { TokensEntity db = physicalSelectOnKey(token); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenUserBadgesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenUserBadgesDao.java new file mode 100644 index 000000000..463d1d424 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenUserBadgesDao.java @@ -0,0 +1,474 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.UserBadgesEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * ユーザの称号 + * this class is auto generate and not edit. + * if modify dao method, you can edit UserBadgesDao. + */ +@DI(instance = Instance.Singleton) +public class GenUserBadgesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenUserBadgesDao get() { + return Container.getComp(GenUserBadgesDao.class); + } + + /** + * Select all data. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, UserBadgesEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, UserBadgesEntity.class, limit, offset); + } + /** + * Select data on key. + * @param no no + * @param userId userId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity physicalSelectOnKey(Integer no, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, UserBadgesEntity.class, no, userId); + } + /** + * Select all data that not deleted. + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, UserBadgesEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); + return executeQueryList(sql, UserBadgesEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param no no + * @param userId userId + * @return data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity selectOnKey(Integer no, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_key.sql"); + return executeQuerySingle(sql, UserBadgesEntity.class, no, userId); + } + /** + * Select data that not deleted on NO column. + * @param no no + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnNo(Integer no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_no.sql"); + return executeQueryList(sql, UserBadgesEntity.class, no); + } + /** + * Select data that not deleted on USER_ID column. + * @param userId userId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectOnUserId(Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_user_id.sql"); + return executeQueryList(sql, UserBadgesEntity.class, userId); + } + /** + * Select data on NO column. + * @param no no + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnNo(Integer no) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_no.sql"); + return executeQueryList(sql, UserBadgesEntity.class, no); + } + /** + * Select data on USER_ID column. + * @param userId userId + * @return list + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectOnUserId(Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_user_id.sql"); + return executeQueryList(sql, UserBadgesEntity.class, userId); + } + /** + * Count all data + * @return count + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM USER_BADGES"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity rawPhysicalInsert(UserBadgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getNo(), + entity.getUserId(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity physicalInsert(UserBadgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_insert.sql"); + executeUpdate(sql, + entity.getNo(), + entity.getUserId(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity insert(Integer user, UserBadgesEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity insert(UserBadgesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity physicalUpdate(UserBadgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_update.sql"); + executeUpdate(sql, + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getNo(), + entity.getUserId()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity update(Integer user, UserBadgesEntity entity) { + UserBadgesEntity db = selectOnKey(entity.getNo(), entity.getUserId()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + return physicalUpdate(entity); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity update(UserBadgesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity save(Integer user, UserBadgesEntity entity) { + UserBadgesEntity db = selectOnKey(entity.getNo(), entity.getUserId()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public UserBadgesEntity save(UserBadgesEntity entity) { + UserBadgesEntity db = selectOnKey(entity.getNo(), entity.getUserId()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param no no + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Integer no, Integer userId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_delete.sql"); + executeUpdate(sql, no, userId); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(UserBadgesEntity entity) { + physicalDelete(entity.getNo(), entity.getUserId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param no no + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Integer no, Integer userId) { + UserBadgesEntity db = selectOnKey(no, userId); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param no no + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer no, Integer userId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, no, userId); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, UserBadgesEntity entity) { + delete(user, entity.getNo(), entity.getUserId()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(UserBadgesEntity entity) { + delete(entity.getNo(), entity.getUserId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param no no + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Integer no, Integer userId) { + UserBadgesEntity db = physicalSelectOnKey(no, userId); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param no no + * @param userId userId + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer no, Integer userId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, no, userId); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, UserBadgesEntity entity) { + activation(user, entity.getNo(), entity.getUserId()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(UserBadgesEntity entity) { + activation(entity.getNo(), entity.getUserId()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java index 5341053d6..560af0970 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenViewHistoriesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ViewHistoriesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ViewHistoriesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offse * @param historyNo historyNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ViewHistoriesEntity physicalSelectOnKey(Long historyNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, ViewHistoriesEntity.class, historyNo); @@ -70,8 +97,19 @@ public ViewHistoriesEntity physicalSelectOnKey(Long historyNo) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ViewHistoriesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, ViewHistoriesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param historyNo historyNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ViewHistoriesEntity selectOnKey(Long historyNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_on_key.sql"); return executeQuerySingle(sql, ViewHistoriesEntity.class, historyNo); @@ -105,6 +158,7 @@ public ViewHistoriesEntity selectOnKey(Long historyNo) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM VIEW_HISTORIES"; return executeQuerySingle(sql, Integer.class); @@ -129,8 +183,13 @@ public ViewHistoriesEntity rawPhysicalInsert(ViewHistoriesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('VIEW_HISTORIES_HISTORY_NO_seq', (select max(HISTORY_NO) from VIEW_HISTORIES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(HISTORY_NO) from VIEW_HISTORIES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('VIEW_HISTORIES_HISTORY_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -165,9 +224,9 @@ public ViewHistoriesEntity physicalInsert(ViewHistoriesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public ViewHistoriesEntity insert(Integer user, ViewHistoriesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -216,7 +275,7 @@ public ViewHistoriesEntity update(Integer user, ViewHistoriesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -293,7 +352,7 @@ public void delete(Integer user, Long historyNo) { ViewHistoriesEntity db = selectOnKey(historyNo); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -342,7 +401,7 @@ public void activation(Integer user, Long historyNo) { ViewHistoriesEntity db = physicalSelectOnKey(historyNo); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java index 748de697d..c9972c6d4 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenVotesDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, VotesEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, VotesEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param voteNo voteNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public VotesEntity physicalSelectOnKey(Long voteNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_on_key.sql"); return executeQuerySingle(sql, VotesEntity.class, voteNo); @@ -70,8 +97,19 @@ public VotesEntity physicalSelectOnKey(Long voteNo) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, VotesEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, VotesEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param voteNo voteNo * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public VotesEntity selectOnKey(Long voteNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_on_key.sql"); return executeQuerySingle(sql, VotesEntity.class, voteNo); @@ -105,6 +158,7 @@ public VotesEntity selectOnKey(Long voteNo) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM VOTES"; return executeQuerySingle(sql, Integer.class); @@ -129,8 +183,13 @@ public VotesEntity rawPhysicalInsert(VotesEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('VOTES_VOTE_NO_seq', (select max(VOTE_NO) from VOTES));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(VOTE_NO) from VOTES;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('VOTES_VOTE_NO_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -165,9 +224,9 @@ public VotesEntity physicalInsert(VotesEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public VotesEntity insert(Integer user, VotesEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -216,7 +275,7 @@ public VotesEntity update(Integer user, VotesEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -293,7 +352,7 @@ public void delete(Integer user, Long voteNo) { VotesEntity db = selectOnKey(voteNo); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -342,7 +401,7 @@ public void activation(Integer user, Long voteNo) { VotesEntity db = physicalSelectOnKey(voteNo); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenWebhookConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenWebhookConfigsDao.java index ecbf46f84..0bcd8c7e3 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenWebhookConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenWebhookConfigsDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenWebhookConfigsDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhookConfigsEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhookConfigsEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offs * @param hookId hookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public WebhookConfigsEntity physicalSelectOnKey(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_on_key.sql"); return executeQuerySingle(sql, WebhookConfigsEntity.class, hookId); @@ -70,8 +97,19 @@ public WebhookConfigsEntity physicalSelectOnKey(Integer hookId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhookConfigsEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhookConfigsEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param hookId hookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public WebhookConfigsEntity selectOnKey(Integer hookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_on_key.sql"); return executeQuerySingle(sql, WebhookConfigsEntity.class, hookId); @@ -105,6 +158,7 @@ public WebhookConfigsEntity selectOnKey(Integer hookId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM WEBHOOK_CONFIGS"; return executeQuerySingle(sql, Integer.class); @@ -129,8 +183,13 @@ public WebhookConfigsEntity rawPhysicalInsert(WebhookConfigsEntity entity) { entity.getDeleteFlag()); String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { - String setValSql = "select setval('WEBHOOK_CONFIGS_HOOK_ID_seq', (select max(HOOK_ID) from WEBHOOK_CONFIGS));"; - executeQuerySingle(setValSql, Long.class); + String maxSql = "SELECT MAX(HOOK_ID) from WEBHOOK_CONFIGS;"; + long max = executeQuerySingle(maxSql, Long.class); + if (max < 1) { + max = 1; + } + String setValSql = "SELECT SETVAL('WEBHOOK_CONFIGS_HOOK_ID_seq', ?);"; + executeQuerySingle(setValSql, Long.class, max); } return entity; } @@ -165,9 +224,9 @@ public WebhookConfigsEntity physicalInsert(WebhookConfigsEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public WebhookConfigsEntity insert(Integer user, WebhookConfigsEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -216,7 +275,7 @@ public WebhookConfigsEntity update(Integer user, WebhookConfigsEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -293,7 +352,7 @@ public void delete(Integer user, Integer hookId) { WebhookConfigsEntity db = selectOnKey(hookId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -342,7 +401,7 @@ public void activation(Integer user, Integer hookId) { WebhookConfigsEntity db = physicalSelectOnKey(hookId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenWebhooksDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenWebhooksDao.java index b92181fa3..7cd9c73b8 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenWebhooksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenWebhooksDao.java @@ -12,8 +12,10 @@ import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.config.Order; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; @@ -43,8 +45,19 @@ public static GenWebhooksDao get() { * Select all data. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAll() { + return physicalSelectAll(Order.DESC); + } + /** + * Select all data. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhooksEntity.class); } /** @@ -53,8 +66,21 @@ public List physicalSelectAll() { * @param offset offset * @return all data on limit and offset */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List physicalSelectAllWithPager(int limit, int offset) { + return physicalSelectAllWithPager(limit, offset, Order.DESC); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data on limit and offset + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List physicalSelectAllWithPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhooksEntity.class, limit, offset); } /** @@ -62,6 +88,7 @@ public List physicalSelectAllWithPager(int limit, int offset) { * @param webhookId webhookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public WebhooksEntity physicalSelectOnKey(String webhookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_on_key.sql"); return executeQuerySingle(sql, WebhooksEntity.class, webhookId); @@ -70,8 +97,19 @@ public WebhooksEntity physicalSelectOnKey(String webhookId) { * Select all data that not deleted. * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAll() { + return selectAll(Order.DESC); + } + /** + * Select all data that not deleted. + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAll(Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhooksEntity.class); } /** @@ -80,14 +118,28 @@ public List selectAll() { * @param offset offset * @return all data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public List selectAllWidthPager(int limit, int offset) { + return selectAllWidthPager(limit, offset, Order.DESC); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @param order order + * @return all data + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List selectAllWidthPager(int limit, int offset, Order order) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all_with_pager.sql"); + sql = String.format(sql, order.toString()); return executeQueryList(sql, WebhooksEntity.class, limit, offset); } /** * Select count that not deleted. * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public Integer selectCountAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_count_all.sql"); return executeQuerySingle(sql, Integer.class); @@ -97,6 +149,7 @@ public Integer selectCountAll() { * @param webhookId webhookId * @return data */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public WebhooksEntity selectOnKey(String webhookId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_on_key.sql"); return executeQuerySingle(sql, WebhooksEntity.class, webhookId); @@ -105,6 +158,7 @@ public WebhooksEntity selectOnKey(String webhookId) { * Count all data * @return count */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public int physicalCountAll() { String sql = "SELECT COUNT(*) FROM WEBHOOKS"; return executeQuerySingle(sql, Integer.class); @@ -161,9 +215,9 @@ public WebhooksEntity physicalInsert(WebhooksEntity entity) { @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public WebhooksEntity insert(Integer user, WebhooksEntity entity) { entity.setInsertUser(user); - entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setInsertDatetime(new Timestamp(DateUtils.now().getTime())); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); entity.setDeleteFlag(0); return physicalInsert(entity); } @@ -213,7 +267,7 @@ public WebhooksEntity update(Integer user, WebhooksEntity entity) { entity.setInsertDatetime(db.getInsertDatetime()); entity.setDeleteFlag(db.getDeleteFlag()); entity.setUpdateUser(user); - entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); return physicalUpdate(entity); } /** @@ -290,7 +344,7 @@ public void delete(Integer user, String webhookId) { WebhooksEntity db = selectOnKey(webhookId); db.setDeleteFlag(1); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** @@ -339,7 +393,7 @@ public void activation(Integer user, String webhookId) { WebhooksEntity db = physicalSelectOnKey(webhookId); db.setDeleteFlag(0); db.setUpdateUser(user); - db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + db.setUpdateDatetime(new Timestamp(DateUtils.now().getTime())); physicalUpdate(db); } /** diff --git a/src/main/java/org/support/project/knowledge/deploy/InitDB.java b/src/main/java/org/support/project/knowledge/deploy/InitDB.java index f71d5c0d4..3dd82b3fd 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitDB.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitDB.java @@ -7,6 +7,8 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.PropertyUtil; +import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.deploy.v0_0_1.InitializeSystem; import org.support.project.knowledge.deploy.v0_4_4.Migrate_0_4_4; import org.support.project.knowledge.deploy.v0_5_0.Migrate_0_5_0; @@ -20,6 +22,11 @@ import org.support.project.knowledge.deploy.v1_10_0.Migrate_1_10_0; import org.support.project.knowledge.deploy.v1_10_0.Migrate_1_10_1; import org.support.project.knowledge.deploy.v1_10_0.Migrate_1_10_2; +import org.support.project.knowledge.deploy.v1_11_0.Migrate_1_11_0; +import org.support.project.knowledge.deploy.v1_11_0.Migrate_1_11_1; +import org.support.project.knowledge.deploy.v1_11_0.Migrate_1_11_2; +import org.support.project.knowledge.deploy.v1_11_0.Migrate_1_11_3; +import org.support.project.knowledge.deploy.v1_11_0.Migrate_1_11_4; import org.support.project.knowledge.deploy.v1_1_0pre1.Migrate_1_1_0pre1; import org.support.project.knowledge.deploy.v1_4_0.Migrate_1_4_0; import org.support.project.knowledge.deploy.v1_5_0.Migrate_1_5_0; @@ -35,6 +42,7 @@ import org.support.project.knowledge.deploy.v1_8_0.Migrate_1_8_5; import org.support.project.web.dao.SystemsDao; import org.support.project.web.entity.SystemsEntity; +import org.support.project.web.logic.DBConnenctionLogic; public class InitDB { /** ログ */ @@ -44,7 +52,7 @@ public class InitDB { private static final Map MAP = new LinkedHashMap<>(); private static final Migrate INIT = InitializeSystem.get(); - public static final String CURRENT = "1.10.2"; + public static final String CURRENT = "1.11.4"; public InitDB() { super(); @@ -74,6 +82,11 @@ public InitDB() { MAP.put("1.10.0", Migrate_1_10_0.get()); MAP.put("1.10.1", Migrate_1_10_1.get()); MAP.put("1.10.2", Migrate_1_10_2.get()); + MAP.put("1.11.0", Migrate_1_11_0.get()); + MAP.put("1.11.1", Migrate_1_11_1.get()); + MAP.put("1.11.2", Migrate_1_11_2.get()); + MAP.put("1.11.3", Migrate_1_11_3.get()); + MAP.put("1.11.4", Migrate_1_11_4.get()); } public static void main(String[] args) throws Exception { @@ -81,11 +94,44 @@ public static void main(String[] args) throws Exception { TimeZone zone = TimeZone.getTimeZone("GMT"); TimeZone.setDefault(zone); + AppConfig.get(); + String envValue = System.getenv(AppConfig.getEnvKey()); + LOG.info("migrate is start."); + if (LOG.isDebugEnabled()) { + LOG.debug("Env [" + AppConfig.getEnvKey() + "] is [" + envValue + "]."); + LOG.debug("Config :" + PropertyUtil.reflectionToString(AppConfig.get())); + } + DBConnenctionLogic.get().connectCustomConnection(); + InitDB init = new InitDB(); init.start(); } + + private String doInit() throws Exception { + String version = CURRENT; + Migrate migrate = INIT; + doMigrate(migrate, version); + return CURRENT; + } + public String init() throws Exception { + SystemsDao dao = SystemsDao.get(); + try { + SystemsEntity entity = dao.selectOnKey(SYSTEM_NAME); + if (entity != null) { + LOG.info("The database of this service is arleady inited. database version is " + entity.getVersion() + "."); + return entity.getVersion(); + } else { + return doInit(); + } + } catch (Exception e) { + // テーブルが存在しない(初めての起動) + return doInit(); + } + } public void start() throws Exception { + LOG.info("Lastest database version is " + CURRENT + " now"); + String version = ""; Migrate migrate; @@ -111,6 +157,7 @@ public void start() throws Exception { doMigrate(migrate, version); return; } + LOG.info("Current database version is " + version + " now"); // バージョンアップ Iterator versions = MAP.keySet().iterator(); diff --git a/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java b/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java index 7de390742..3e5a09846 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java @@ -1,20 +1,17 @@ package org.support.project.knowledge.deploy; import java.io.File; -import java.util.List; +import java.util.TimeZone; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.support.project.common.exception.SystemException; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.knowledge.config.AnalyticsConfig; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; -import org.support.project.knowledge.dao.ServiceConfigsDao; -import org.support.project.knowledge.dao.ServiceLocaleConfigsDao; -import org.support.project.knowledge.entity.ServiceConfigsEntity; -import org.support.project.knowledge.entity.ServiceLocaleConfigsEntity; import org.support.project.knowledge.logic.ServiceConfigLogic; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.web.dao.SystemAttributesDao; @@ -35,7 +32,16 @@ public void contextDestroyed(ServletContextEvent contextEvent) { @Override public void contextInitialized(ServletContextEvent contextEvent) { LOG.debug("contextInitialized"); - InitializationLogic.get().init(); + // DBの初期化処理 + TimeZone zone = TimeZone.getTimeZone("GMT"); + TimeZone.setDefault(zone); + InitDB initDB = new InitDB(); + String version; + try { + version = initDB.init(); + } catch (Exception e) { + throw new SystemException(e); + } // 添付ファイル格納ディレクトリ(テンポラリディレクトリ)が存在しなければ生成 AppConfig appConfig = AppConfig.get(); @@ -66,6 +72,12 @@ public void contextInitialized(ServletContextEvent contextEvent) { // トップページ情報を取得 ServiceConfigLogic.get().load(); + + if (!InitDB.CURRENT.equals(version)) { + // Databaseのマイグレーションが必要 + appConfig.setMaintenanceMode(true); + LOG.warn("The database version of this service is " + version + ". but lastest version is " + InitDB.CURRENT + ". Then this service start MaintenanceMode"); + } } } diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_0.java b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_0.java new file mode 100644 index 000000000..34afd71c2 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_0.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.deploy.v1_11_0; + +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_11_0 implements Migrate { + + public static Migrate_1_11_0 get() { + return org.support.project.di.Container.getComp(Migrate_1_11_0.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_0.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_1.java b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_1.java new file mode 100644 index 000000000..a72932e2c --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_1.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.deploy.v1_11_0; + +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_11_1 implements Migrate { + + public static Migrate_1_11_1 get() { + return org.support.project.di.Container.getComp(Migrate_1_11_1.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_1.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_2.java b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_2.java new file mode 100644 index 000000000..07b27bd8e --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_2.java @@ -0,0 +1,27 @@ +package org.support.project.knowledge.deploy.v1_11_0; + +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.knowledge.logic.AggregateLogic; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_11_2 implements Migrate { + public static Migrate_1_11_2 get() { + return org.support.project.di.Container.getComp(Migrate_1_11_2.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_2.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + + AggregateLogic aggregateLogic = AggregateLogic.get(); + aggregateLogic.startAggregate(); + + return true; + } + + +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_3.java b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_3.java new file mode 100644 index 000000000..05ffb887f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_3.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.deploy.v1_11_0; + +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_11_3 implements Migrate { + + public static Migrate_1_11_3 get() { + return org.support.project.di.Container.getComp(Migrate_1_11_3.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_3.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_4.java b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_4.java new file mode 100644 index 000000000..19cc4d671 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_11_0/Migrate_1_11_4.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.deploy.v1_11_0; + +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_11_4 implements Migrate { + + public static Migrate_1_11_4 get() { + return org.support.project.di.Container.getComp(Migrate_1_11_4.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_4.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/entity/ActivitiesEntity.java b/src/main/java/org/support/project/knowledge/entity/ActivitiesEntity.java new file mode 100644 index 000000000..d3924b4e4 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/ActivitiesEntity.java @@ -0,0 +1,65 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenActivitiesEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * アクティビティ + */ +@DI(instance = Instance.Prototype) +public class ActivitiesEntity extends GenActivitiesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + private String userName = ""; + + /** + * Get instance from DI container. + * @return instance + */ + public static ActivitiesEntity get() { + return Container.getComp(ActivitiesEntity.class); + } + + /** + * Constructor. + */ + public ActivitiesEntity() { + super(); + } + + /** + * Constructor + * @param no 番号 + */ + + public ActivitiesEntity(Long no) { + super( no); + } + + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + + /** + * @param userName the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/BadgesEntity.java b/src/main/java/org/support/project/knowledge/entity/BadgesEntity.java new file mode 100644 index 000000000..f68781ee4 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/BadgesEntity.java @@ -0,0 +1,49 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenBadgesEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * 称号 + */ +@DI(instance = Instance.Prototype) +public class BadgesEntity extends GenBadgesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static BadgesEntity get() { + return Container.getComp(BadgesEntity.class); + } + + /** + * Constructor. + */ + public BadgesEntity() { + super(); + } + + /** + * Constructor + * @param no 番号 + */ + + public BadgesEntity(Integer no) { + super( no); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/CommentsEntity.java b/src/main/java/org/support/project/knowledge/entity/CommentsEntity.java index eeeb73eed..027f8fea7 100644 --- a/src/main/java/org/support/project/knowledge/entity/CommentsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/CommentsEntity.java @@ -18,6 +18,8 @@ public class CommentsEntity extends GenCommentsEntity { private String insertUserName; /** 更新ユーザ名 */ private String updateUserName; + + private long likeCount = 0; public boolean isUpdate() { if (getInsertDatetime().getTime() != getUpdateDatetime().getTime()) { @@ -80,4 +82,18 @@ public void setInsertUserName(String insertUserName) { this.insertUserName = insertUserName; } + /** + * @return the likeCount + */ + public long getLikeCount() { + return likeCount; + } + + /** + * @param likeCount the likeCount to set + */ + public void setLikeCount(long likeCount) { + this.likeCount = likeCount; + } + } diff --git a/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java b/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java index e90f1e38f..1119ab852 100644 --- a/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java @@ -41,7 +41,7 @@ public static KnowledgesEntity get() { /** スコア(検索した際のスコア) */ private Float score; /** 指定期間内のイイネ件数 */ - private Integer likeCountOnTerm; + private Integer pointOnTerm; /** 開催日 UTC(Eventの場合のみ) */ private Timestamp startDateTime; @@ -66,6 +66,16 @@ public KnowledgesEntity(Long knowledgeId) { super(knowledgeId); } + /** + * Get 参照件数.(Safe null) + * @return 参照件数 + */ + public Long getViewCount() { + if (super.getViewCount() == null) return new Long(0); + return super.getViewCount(); + } + + /** * 開始日時を指定のタイムゾーンの日時として取得 * @param locale @@ -159,31 +169,31 @@ public void setScore(Float score) { } /** - * @return the likeCountOnTerm + * @return the startDateTime */ - public Integer getLikeCountOnTerm() { - return likeCountOnTerm; + public Timestamp getStartDateTime() { + return startDateTime; } /** - * @param likeCountOnTerm the likeCountOnTerm to set + * @param startDateTime the startDateTime to set */ - public void setLikeCountOnTerm(Integer likeCountOnTerm) { - this.likeCountOnTerm = likeCountOnTerm; + public void setStartDateTime(Timestamp startDateTime) { + this.startDateTime = startDateTime; } /** - * @return the startDateTime + * @return the pointOnTerm */ - public Timestamp getStartDateTime() { - return startDateTime; + public Integer getPointOnTerm() { + return pointOnTerm; } /** - * @param startDateTime the startDateTime to set + * @param pointOnTerm the pointOnTerm to set */ - public void setStartDateTime(Timestamp startDateTime) { - this.startDateTime = startDateTime; + public void setPointOnTerm(Integer pointOnTerm) { + this.pointOnTerm = pointOnTerm; } } diff --git a/src/main/java/org/support/project/knowledge/entity/LikeCommentsEntity.java b/src/main/java/org/support/project/knowledge/entity/LikeCommentsEntity.java new file mode 100644 index 000000000..b80134181 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/LikeCommentsEntity.java @@ -0,0 +1,58 @@ +package org.support.project.knowledge.entity; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.entity.gen.GenLikeCommentsEntity; + + +/** + * コメントのイイネ + */ +@DI(instance = Instance.Prototype) +public class LikeCommentsEntity extends GenLikeCommentsEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + private String userName; + + /** + * Get instance from DI container. + * @return instance + */ + public static LikeCommentsEntity get() { + return Container.getComp(LikeCommentsEntity.class); + } + + /** + * Constructor. + */ + public LikeCommentsEntity() { + super(); + } + + /** + * Constructor + * @param no NO + */ + + public LikeCommentsEntity(Long no) { + super( no); + } + + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + + /** + * @param userName the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/MailHookIgnoreConditionsEntity.java b/src/main/java/org/support/project/knowledge/entity/MailHookIgnoreConditionsEntity.java new file mode 100644 index 000000000..c07a0277a --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/MailHookIgnoreConditionsEntity.java @@ -0,0 +1,51 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenMailHookIgnoreConditionsEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * メールから投稿の際の除外条件 + */ +@DI(instance = Instance.Prototype) +public class MailHookIgnoreConditionsEntity extends GenMailHookIgnoreConditionsEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static MailHookIgnoreConditionsEntity get() { + return Container.getComp(MailHookIgnoreConditionsEntity.class); + } + + /** + * Constructor. + */ + public MailHookIgnoreConditionsEntity() { + super(); + } + + /** + * Constructor + * @param conditionNo CONDITION_NO + * @param hookId HOOK_ID + * @param ignoreConditionNo IGNORE_CONDITION_NO + */ + + public MailHookIgnoreConditionsEntity(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + super( conditionNo, hookId, ignoreConditionNo); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/NotificationStatusEntity.java b/src/main/java/org/support/project/knowledge/entity/NotificationStatusEntity.java new file mode 100644 index 000000000..2c0040f01 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/NotificationStatusEntity.java @@ -0,0 +1,51 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenNotificationStatusEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * いいねの通知状態 + */ +@DI(instance = Instance.Prototype) +public class NotificationStatusEntity extends GenNotificationStatusEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static NotificationStatusEntity get() { + return Container.getComp(NotificationStatusEntity.class); + } + + /** + * Constructor. + */ + public NotificationStatusEntity() { + super(); + } + + /** + * Constructor + * @param id ターゲットのID + * @param type 種類 + * @param user 登録者 + */ + + public NotificationStatusEntity(Long id, Integer type, Integer user) { + super( id, type, user); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/PointKnowledgeHistoriesEntity.java b/src/main/java/org/support/project/knowledge/entity/PointKnowledgeHistoriesEntity.java new file mode 100644 index 000000000..02d9d6ed7 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/PointKnowledgeHistoriesEntity.java @@ -0,0 +1,50 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenPointKnowledgeHistoriesEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * ナレッジのポイント獲得履歴 + */ +@DI(instance = Instance.Prototype) +public class PointKnowledgeHistoriesEntity extends GenPointKnowledgeHistoriesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static PointKnowledgeHistoriesEntity get() { + return Container.getComp(PointKnowledgeHistoriesEntity.class); + } + + /** + * Constructor. + */ + public PointKnowledgeHistoriesEntity() { + super(); + } + + /** + * Constructor + * @param historyNo 履歴番号 + * @param knowledgeId ナレッジID + */ + + public PointKnowledgeHistoriesEntity(Long historyNo, Long knowledgeId) { + super( historyNo, knowledgeId); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/PointUserHistoriesEntity.java b/src/main/java/org/support/project/knowledge/entity/PointUserHistoriesEntity.java new file mode 100644 index 000000000..47459c8af --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/PointUserHistoriesEntity.java @@ -0,0 +1,50 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenPointUserHistoriesEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * ユーザのポイント獲得履歴 + */ +@DI(instance = Instance.Prototype) +public class PointUserHistoriesEntity extends GenPointUserHistoriesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static PointUserHistoriesEntity get() { + return Container.getComp(PointUserHistoriesEntity.class); + } + + /** + * Constructor. + */ + public PointUserHistoriesEntity() { + super(); + } + + /** + * Constructor + * @param historyNo 履歴番号 + * @param userId ユーザID + */ + + public PointUserHistoriesEntity(Long historyNo, Integer userId) { + super( historyNo, userId); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java b/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java index e4cfca0b1..b1510d31f 100644 --- a/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java @@ -21,6 +21,8 @@ public class SurveysEntity extends GenSurveysEntity { private String knowledgeTitle; + private boolean exist = false; + /** SerialVersion */ private static final long serialVersionUID = 1L; @@ -90,4 +92,18 @@ public void setKnowledgeTitle(String knowledgeTitle) { this.knowledgeTitle = knowledgeTitle; } + /** + * @return the exist + */ + public boolean isExist() { + return exist; + } + + /** + * @param exist the exist to set + */ + public void setExist(boolean exist) { + this.exist = exist; + } + } diff --git a/src/main/java/org/support/project/knowledge/entity/UserBadgesEntity.java b/src/main/java/org/support/project/knowledge/entity/UserBadgesEntity.java new file mode 100644 index 000000000..060308566 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/UserBadgesEntity.java @@ -0,0 +1,50 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenUserBadgesEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * ユーザの称号 + */ +@DI(instance = Instance.Prototype) +public class UserBadgesEntity extends GenUserBadgesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static UserBadgesEntity get() { + return Container.getComp(UserBadgesEntity.class); + } + + /** + * Constructor. + */ + public UserBadgesEntity() { + super(); + } + + /** + * Constructor + * @param no 番号 + * @param userId ユーザID + */ + + public UserBadgesEntity(Integer no, Integer userId) { + super( no, userId); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenActivitiesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenActivitiesEntity.java new file mode 100644 index 000000000..b9e5eb558 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenActivitiesEntity.java @@ -0,0 +1,394 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * アクティビティ + */ +@DI(instance = Instance.Prototype) +public class GenActivitiesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenActivitiesEntity get() { + return Container.getComp(GenActivitiesEntity.class); + } + + /** + * Constructor. + */ + public GenActivitiesEntity() { + super(); + } + + /** + * Constructor + * @param activityNo アクティビティ番号 + */ + + public GenActivitiesEntity(Long activityNo) { + super(); + this.activityNo = activityNo; + } + /** アクティビティ番号 */ + private Long activityNo; + /** イベントをおこしたユーザ */ + private Integer userId; + /** アクティビティの種類 */ + private Integer kind; + /** ターゲットID */ + private String target; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get アクティビティ番号. + * @return アクティビティ番号 + */ + public Long getActivityNo() { + return this.activityNo; + } + /** + * Set アクティビティ番号. + * @param activityNo アクティビティ番号 + * @return this object */ + public GenActivitiesEntity setActivityNo(Long activityNo) { + this.activityNo = activityNo; + return this; + } + + /** + * Get イベントをおこしたユーザ. + * @return イベントをおこしたユーザ + */ + public Integer getUserId() { + return this.userId; + } + /** + * Set イベントをおこしたユーザ. + * @param userId イベントをおこしたユーザ + * @return this object */ + public GenActivitiesEntity setUserId(Integer userId) { + this.userId = userId; + return this; + } + + /** + * Get アクティビティの種類. + * @return アクティビティの種類 + */ + public Integer getKind() { + return this.kind; + } + /** + * Set アクティビティの種類. + * @param kind アクティビティの種類 + * @return this object */ + public GenActivitiesEntity setKind(Integer kind) { + this.kind = kind; + return this; + } + + /** + * Get ターゲットID. + * @return ターゲットID + */ + public String getTarget() { + return this.target; + } + /** + * Set ターゲットID. + * @param target ターゲットID + * @return this object */ + public GenActivitiesEntity setTarget(String target) { + this.target = target; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenActivitiesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenActivitiesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenActivitiesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenActivitiesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenActivitiesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[1]; + keyValues[0] = this.activityNo; + return keyValues; + } + /** + * Set key values + * @param activityNo アクティビティ番号 + */ + public void setKeyValues(Long activityNo) { + this.activityNo = activityNo; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenActivitiesEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("activityNo = ").append(activityNo).append("\n"); + builder.append("userId = ").append(userId).append("\n"); + builder.append("kind = ").append(kind).append("\n"); + builder.append("target = ").append(target).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.kind, convLabelName("Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.kind, convLabelName("Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.target, convLabelName("Target")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.target, convLabelName("Target"), 64); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("kind"), convLabelName("Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("kind"), convLabelName("Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("target"), convLabelName("Target")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("target"), convLabelName("Target"), 64); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenBadgesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenBadgesEntity.java new file mode 100644 index 000000000..8029db0ca --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenBadgesEntity.java @@ -0,0 +1,442 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * 称号 + */ +@DI(instance = Instance.Prototype) +public class GenBadgesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenBadgesEntity get() { + return Container.getComp(GenBadgesEntity.class); + } + + /** + * Constructor. + */ + public GenBadgesEntity() { + super(); + } + + /** + * Constructor + * @param no 番号 + */ + + public GenBadgesEntity(Integer no) { + super(); + this.no = no; + } + /** 番号 */ + private Integer no; + /** 名称 */ + private String name; + /** 表示名 */ + private String displayText; + /** 説明 */ + private String description; + /** 画像 */ + private String image; + /** 獲得ポイント */ + private Integer point; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get 番号. + * @return 番号 + */ + public Integer getNo() { + return this.no; + } + /** + * Set 番号. + * @param no 番号 + * @return this object */ + public GenBadgesEntity setNo(Integer no) { + this.no = no; + return this; + } + + /** + * Get 名称. + * @return 名称 + */ + public String getName() { + return this.name; + } + /** + * Set 名称. + * @param name 名称 + * @return this object */ + public GenBadgesEntity setName(String name) { + this.name = name; + return this; + } + + /** + * Get 表示名. + * @return 表示名 + */ + public String getDisplayText() { + return this.displayText; + } + /** + * Set 表示名. + * @param displayText 表示名 + * @return this object */ + public GenBadgesEntity setDisplayText(String displayText) { + this.displayText = displayText; + return this; + } + + /** + * Get 説明. + * @return 説明 + */ + public String getDescription() { + return this.description; + } + /** + * Set 説明. + * @param description 説明 + * @return this object */ + public GenBadgesEntity setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get 画像. + * @return 画像 + */ + public String getImage() { + return this.image; + } + /** + * Set 画像. + * @param image 画像 + * @return this object */ + public GenBadgesEntity setImage(String image) { + this.image = image; + return this; + } + + /** + * Get 獲得ポイント. + * @return 獲得ポイント + */ + public Integer getPoint() { + return this.point; + } + /** + * Set 獲得ポイント. + * @param point 獲得ポイント + * @return this object */ + public GenBadgesEntity setPoint(Integer point) { + this.point = point; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenBadgesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenBadgesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenBadgesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenBadgesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenBadgesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[1]; + keyValues[0] = this.no; + return keyValues; + } + /** + * Set key values + * @param no 番号 + */ + public void setKeyValues(Integer no) { + this.no = no; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenBadgesEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("no = ").append(no).append("\n"); + builder.append("name = ").append(name).append("\n"); + builder.append("displayText = ").append(displayText).append("\n"); + builder.append("description = ").append(description).append("\n"); + builder.append("image = ").append(image).append("\n"); + builder.append("point = ").append(point).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.no, convLabelName("No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.name, convLabelName("Name")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.name, convLabelName("Name"), 128); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.displayText, convLabelName("Display Text")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.displayText, convLabelName("Display Text"), 32); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.image, convLabelName("Image"), 64); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("no"), convLabelName("No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("name"), convLabelName("Name")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("name"), convLabelName("Name"), 128); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("displayText"), convLabelName("Display Text")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("displayText"), convLabelName("Display Text"), 32); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("image"), convLabelName("Image"), 64); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java index 2280f2463..97929bd13 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java @@ -51,7 +51,7 @@ public GenEventsEntity(Long knowledgeId) { } /** ナレッジID */ private Long knowledgeId; - /** 開催日 UTC */ + /** 開催日 UTC */ private Timestamp startDateTime; /** タイムゾーン */ private String timeZone; @@ -85,15 +85,15 @@ public GenEventsEntity setKnowledgeId(Long knowledgeId) { } /** - * Get 開催日 UTC. - * @return 開催日 UTC + * Get 開催日 UTC. + * @return 開催日 UTC */ public Timestamp getStartDateTime() { return this.startDateTime; } /** - * Set 開催日 UTC. - * @param startDateTime 開催日 UTC + * Set 開催日 UTC. + * @param startDateTime 開催日 UTC * @return this object */ public GenEventsEntity setStartDateTime(Timestamp startDateTime) { this.startDateTime = startDateTime; diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgesEntity.java index e63499d45..97f242a7e 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgesEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgesEntity.java @@ -65,10 +65,14 @@ public GenKnowledgesEntity(Long knowledgeId) { private Long likeCount; /** コメント件数 */ private Integer commentCount; + /** 参照件数 */ + private Long viewCount; /** テンプレートの種類ID */ private Integer typeId; /** 通知ステータス */ private Integer notifyStatus; + /** ポイント */ + private Integer point; /** 登録ユーザ */ private Integer insertUser; /** 登録日時 */ @@ -208,6 +212,22 @@ public GenKnowledgesEntity setCommentCount(Integer commentCount) { return this; } + /** + * Get 参照件数. + * @return 参照件数 + */ + public Long getViewCount() { + return this.viewCount; + } + /** + * Set 参照件数. + * @param viewCount 参照件数 + * @return this object */ + public GenKnowledgesEntity setViewCount(Long viewCount) { + this.viewCount = viewCount; + return this; + } + /** * Get テンプレートの種類ID. * @return テンプレートの種類ID @@ -240,6 +260,22 @@ public GenKnowledgesEntity setNotifyStatus(Integer notifyStatus) { return this; } + /** + * Get ポイント. + * @return ポイント + */ + public Integer getPoint() { + return this.point; + } + /** + * Set ポイント. + * @param point ポイント + * @return this object */ + public GenKnowledgesEntity setPoint(Integer point) { + this.point = point; + return this; + } + /** * Get 登録ユーザ. * @return 登録ユーザ @@ -376,8 +412,10 @@ public String toString() { builder.append("tagNames = ").append(tagNames).append("\n"); builder.append("likeCount = ").append(likeCount).append("\n"); builder.append("commentCount = ").append(commentCount).append("\n"); + builder.append("viewCount = ").append(viewCount).append("\n"); builder.append("typeId = ").append(typeId).append("\n"); builder.append("notifyStatus = ").append(notifyStatus).append("\n"); + builder.append("point = ").append(point).append("\n"); builder.append("insertUser = ").append(insertUser).append("\n"); builder.append("insertDatetime = ").append(insertDatetime).append("\n"); builder.append("updateUser = ").append(updateUser).append("\n"); @@ -436,6 +474,16 @@ public List validate() { if (error != null) { errors.add(error); } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } validator = ValidatorFactory.getInstance(Validator.INTEGER); error = validator.validate(this.insertUser, convLabelName("Insert User")); if (error != null) { @@ -497,6 +545,16 @@ public List validate(Map values) { if (error != null) { errors.add(error); } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } validator = ValidatorFactory.getInstance(Validator.INTEGER); error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); if (error != null) { diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenLikeCommentsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenLikeCommentsEntity.java new file mode 100644 index 000000000..78776d793 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenLikeCommentsEntity.java @@ -0,0 +1,335 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * コメントのイイネ + */ +@DI(instance = Instance.Prototype) +public class GenLikeCommentsEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenLikeCommentsEntity get() { + return Container.getComp(GenLikeCommentsEntity.class); + } + + /** + * Constructor. + */ + public GenLikeCommentsEntity() { + super(); + } + + /** + * Constructor + * @param no NO + */ + + public GenLikeCommentsEntity(Long no) { + super(); + this.no = no; + } + /** NO */ + private Long no; + /** コメント番号 */ + private Long commentNo; + /** 種類 */ + private Integer likeClass; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get NO. + * @return NO + */ + public Long getNo() { + return this.no; + } + /** + * Set NO. + * @param no NO + * @return this object */ + public GenLikeCommentsEntity setNo(Long no) { + this.no = no; + return this; + } + + /** + * Get コメント番号. + * @return コメント番号 + */ + public Long getCommentNo() { + return this.commentNo; + } + /** + * Set コメント番号. + * @param commentNo コメント番号 + * @return this object */ + public GenLikeCommentsEntity setCommentNo(Long commentNo) { + this.commentNo = commentNo; + return this; + } + + /** + * Get 種類. + * @return 種類 + */ + public Integer getLikeClass() { + return this.likeClass; + } + /** + * Set 種類. + * @param likeClass 種類 + * @return this object */ + public GenLikeCommentsEntity setLikeClass(Integer likeClass) { + this.likeClass = likeClass; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenLikeCommentsEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenLikeCommentsEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenLikeCommentsEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenLikeCommentsEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenLikeCommentsEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[1]; + keyValues[0] = this.no; + return keyValues; + } + /** + * Set key values + * @param no NO + */ + public void setKeyValues(Long no) { + this.no = no; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenLikeCommentsEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("no = ").append(no).append("\n"); + builder.append("commentNo = ").append(commentNo).append("\n"); + builder.append("likeClass = ").append(likeClass).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.commentNo, convLabelName("Comment No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.likeClass, convLabelName("Like Class")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("commentNo"), convLabelName("Comment No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("likeClass"), convLabelName("Like Class")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenLikesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenLikesEntity.java index 5ff982bb8..a10d2dff4 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenLikesEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenLikesEntity.java @@ -53,6 +53,8 @@ public GenLikesEntity(Long no) { private Long no; /** ナレッジID */ private Long knowledgeId; + /** 種類 */ + private Integer likeClass; /** 登録ユーザ */ private Integer insertUser; /** 登録日時 */ @@ -96,6 +98,22 @@ public GenLikesEntity setKnowledgeId(Long knowledgeId) { return this; } + /** + * Get 種類. + * @return 種類 + */ + public Integer getLikeClass() { + return this.likeClass; + } + /** + * Set 種類. + * @param likeClass 種類 + * @return this object */ + public GenLikesEntity setLikeClass(Integer likeClass) { + this.likeClass = likeClass; + return this; + } + /** * Get 登録ユーザ. * @return 登録ユーザ @@ -226,6 +244,7 @@ public String toString() { StringBuilder builder = new StringBuilder(); builder.append("no = ").append(no).append("\n"); builder.append("knowledgeId = ").append(knowledgeId).append("\n"); + builder.append("likeClass = ").append(likeClass).append("\n"); builder.append("insertUser = ").append(insertUser).append("\n"); builder.append("insertDatetime = ").append(insertDatetime).append("\n"); builder.append("updateUser = ").append(updateUser).append("\n"); @@ -255,6 +274,11 @@ public List validate() { errors.add(error); } validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.likeClass, convLabelName("Like Class")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); error = validator.validate(this.insertUser, convLabelName("Insert User")); if (error != null) { errors.add(error); @@ -286,6 +310,11 @@ public List validate(Map values) { errors.add(error); } validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("likeClass"), convLabelName("Like Class")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); if (error != null) { errors.add(error); diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java index 5b35fb4ac..58cc721aa 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java @@ -55,13 +55,13 @@ public GenMailHookConditionsEntity(Integer conditionNo, Integer hookId) { private Integer hookId; /** CONDITION_NO */ private Integer conditionNo; - /** 条件の種類 1:宛先が「条件文字」であった場合 */ + /** 条件の種類 1:宛先が「条件文字」であった場合 */ private Integer conditionKind; /** 条件の文字 */ private String condition; /** 投稿者 */ private Integer processUser; - /** 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 */ + /** 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 */ private Integer processUserKind; /** 公開区分 */ private Integer publicFlag; @@ -119,15 +119,15 @@ public GenMailHookConditionsEntity setConditionNo(Integer conditionNo) { } /** - * Get 条件の種類 1:宛先が「条件文字」であった場合. - * @return 条件の種類 1:宛先が「条件文字」であった場合 + * Get 条件の種類 1:宛先が「条件文字」であった場合. + * @return 条件の種類 1:宛先が「条件文字」であった場合 */ public Integer getConditionKind() { return this.conditionKind; } /** - * Set 条件の種類 1:宛先が「条件文字」であった場合. - * @param conditionKind 条件の種類 1:宛先が「条件文字」であった場合 + * Set 条件の種類 1:宛先が「条件文字」であった場合. + * @param conditionKind 条件の種類 1:宛先が「条件文字」であった場合 * @return this object */ public GenMailHookConditionsEntity setConditionKind(Integer conditionKind) { this.conditionKind = conditionKind; @@ -167,15 +167,15 @@ public GenMailHookConditionsEntity setProcessUser(Integer processUser) { } /** - * Get 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. - * @return 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 + * Get 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. + * @return 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 */ public Integer getProcessUserKind() { return this.processUserKind; } /** - * Set 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. - * @param processUserKind 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 + * Set 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. + * @param processUserKind 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 * @return this object */ public GenMailHookConditionsEntity setProcessUserKind(Integer processUserKind) { this.processUserKind = processUserKind; diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookIgnoreConditionsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookIgnoreConditionsEntity.java new file mode 100644 index 000000000..5b1ef716e --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookIgnoreConditionsEntity.java @@ -0,0 +1,453 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * メールから投稿の際の除外条件 + */ +@DI(instance = Instance.Prototype) +public class GenMailHookIgnoreConditionsEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenMailHookIgnoreConditionsEntity get() { + return Container.getComp(GenMailHookIgnoreConditionsEntity.class); + } + + /** + * Constructor. + */ + public GenMailHookIgnoreConditionsEntity() { + super(); + } + + /** + * Constructor + * @param conditionNo CONDITION_NO + * @param hookId HOOK_ID + * @param ignoreConditionNo IGNORE_CONDITION_NO + */ + + public GenMailHookIgnoreConditionsEntity(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + super(); + this.conditionNo = conditionNo; + this.hookId = hookId; + this.ignoreConditionNo = ignoreConditionNo; + } + /** HOOK_ID */ + private Integer hookId; + /** CONDITION_NO */ + private Integer conditionNo; + /** IGNORE_CONDITION_NO */ + private Integer ignoreConditionNo; + /** 条件の種類 1:宛先が「条件文字」であった場合 */ + private Integer conditionKind; + /** 条件の文字 */ + private String condition; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get HOOK_ID. + * @return HOOK_ID + */ + public Integer getHookId() { + return this.hookId; + } + /** + * Set HOOK_ID. + * @param hookId HOOK_ID + * @return this object */ + public GenMailHookIgnoreConditionsEntity setHookId(Integer hookId) { + this.hookId = hookId; + return this; + } + + /** + * Get CONDITION_NO. + * @return CONDITION_NO + */ + public Integer getConditionNo() { + return this.conditionNo; + } + /** + * Set CONDITION_NO. + * @param conditionNo CONDITION_NO + * @return this object */ + public GenMailHookIgnoreConditionsEntity setConditionNo(Integer conditionNo) { + this.conditionNo = conditionNo; + return this; + } + + /** + * Get IGNORE_CONDITION_NO. + * @return IGNORE_CONDITION_NO + */ + public Integer getIgnoreConditionNo() { + return this.ignoreConditionNo; + } + /** + * Set IGNORE_CONDITION_NO. + * @param ignoreConditionNo IGNORE_CONDITION_NO + * @return this object */ + public GenMailHookIgnoreConditionsEntity setIgnoreConditionNo(Integer ignoreConditionNo) { + this.ignoreConditionNo = ignoreConditionNo; + return this; + } + + /** + * Get 条件の種類 1:宛先が「条件文字」であった場合. + * @return 条件の種類 1:宛先が「条件文字」であった場合 + */ + public Integer getConditionKind() { + return this.conditionKind; + } + /** + * Set 条件の種類 1:宛先が「条件文字」であった場合. + * @param conditionKind 条件の種類 1:宛先が「条件文字」であった場合 + * @return this object */ + public GenMailHookIgnoreConditionsEntity setConditionKind(Integer conditionKind) { + this.conditionKind = conditionKind; + return this; + } + + /** + * Get 条件の文字. + * @return 条件の文字 + */ + public String getCondition() { + return this.condition; + } + /** + * Set 条件の文字. + * @param condition 条件の文字 + * @return this object */ + public GenMailHookIgnoreConditionsEntity setCondition(String condition) { + this.condition = condition; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenMailHookIgnoreConditionsEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenMailHookIgnoreConditionsEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenMailHookIgnoreConditionsEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenMailHookIgnoreConditionsEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenMailHookIgnoreConditionsEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[3]; + keyValues[0] = this.conditionNo; + keyValues[1] = this.hookId; + keyValues[2] = this.ignoreConditionNo; + return keyValues; + } + /** + * Set key values + * @param conditionNo CONDITION_NO + * @param hookId HOOK_ID + * @param ignoreConditionNo IGNORE_CONDITION_NO + */ + public void setKeyValues(Integer conditionNo, Integer hookId, Integer ignoreConditionNo) { + this.conditionNo = conditionNo; + this.hookId = hookId; + this.ignoreConditionNo = ignoreConditionNo; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenMailHookIgnoreConditionsEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("conditionNo = ").append(conditionNo).append("\n"); + builder.append("hookId = ").append(hookId).append("\n"); + builder.append("ignoreConditionNo = ").append(ignoreConditionNo).append("\n"); + builder.append("conditionKind = ").append(conditionKind).append("\n"); + builder.append("condition = ").append(condition).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.hookId, convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.hookId, convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.conditionNo, convLabelName("Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.conditionNo, convLabelName("Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.ignoreConditionNo, convLabelName("Ignore Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.ignoreConditionNo, convLabelName("Ignore Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.conditionKind, convLabelName("Condition Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.conditionKind, convLabelName("Condition Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.condition, convLabelName("Condition"), 256); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("hookId"), convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("hookId"), convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("conditionNo"), convLabelName("Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("conditionNo"), convLabelName("Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("ignoreConditionNo"), convLabelName("Ignore Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("ignoreConditionNo"), convLabelName("Ignore Condition No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("conditionKind"), convLabelName("Condition Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("conditionKind"), convLabelName("Condition Kind")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("condition"), convLabelName("Condition"), 256); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java index 4ea8071cc..8f54e0736 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java @@ -51,7 +51,7 @@ public GenMailPostsEntity(String messageId) { } /** Message-ID */ private String messageId; - /** 投稿区分 1: Knowledge 2:Comment */ + /** 投稿区分 1: Knowledge 2:Comment */ private Integer postKind; /** ID */ private Long id; @@ -85,15 +85,15 @@ public GenMailPostsEntity setMessageId(String messageId) { } /** - * Get 投稿区分 1: Knowledge 2:Comment. - * @return 投稿区分 1: Knowledge 2:Comment + * Get 投稿区分 1: Knowledge 2:Comment. + * @return 投稿区分 1: Knowledge 2:Comment */ public Integer getPostKind() { return this.postKind; } /** - * Set 投稿区分 1: Knowledge 2:Comment. - * @param postKind 投稿区分 1: Knowledge 2:Comment + * Set 投稿区分 1: Knowledge 2:Comment. + * @param postKind 投稿区分 1: Knowledge 2:Comment * @return this object */ public GenMailPostsEntity setPostKind(Integer postKind) { this.postKind = postKind; diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenNotificationStatusEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenNotificationStatusEntity.java new file mode 100644 index 000000000..7a9acee67 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenNotificationStatusEntity.java @@ -0,0 +1,404 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * いいねの通知状態 + */ +@DI(instance = Instance.Prototype) +public class GenNotificationStatusEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenNotificationStatusEntity get() { + return Container.getComp(GenNotificationStatusEntity.class); + } + + /** + * Constructor. + */ + public GenNotificationStatusEntity() { + super(); + } + + /** + * Constructor + * @param targetId ターゲットのID + * @param type 種類 + * @param userId 登録者 + */ + + public GenNotificationStatusEntity(Long targetId, Integer type, Integer userId) { + super(); + this.targetId = targetId; + this.type = type; + this.userId = userId; + } + /** 種類 */ + private Integer type; + /** ターゲットのID */ + private Long targetId; + /** 登録者 */ + private Integer userId; + /** 通知の状態 */ + private Integer status; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get 種類. + * @return 種類 + */ + public Integer getType() { + return this.type; + } + /** + * Set 種類. + * @param type 種類 + * @return this object */ + public GenNotificationStatusEntity setType(Integer type) { + this.type = type; + return this; + } + + /** + * Get ターゲットのID. + * @return ターゲットのID + */ + public Long getTargetId() { + return this.targetId; + } + /** + * Set ターゲットのID. + * @param targetId ターゲットのID + * @return this object */ + public GenNotificationStatusEntity setTargetId(Long targetId) { + this.targetId = targetId; + return this; + } + + /** + * Get 登録者. + * @return 登録者 + */ + public Integer getUserId() { + return this.userId; + } + /** + * Set 登録者. + * @param userId 登録者 + * @return this object */ + public GenNotificationStatusEntity setUserId(Integer userId) { + this.userId = userId; + return this; + } + + /** + * Get 通知の状態. + * @return 通知の状態 + */ + public Integer getStatus() { + return this.status; + } + /** + * Set 通知の状態. + * @param status 通知の状態 + * @return this object */ + public GenNotificationStatusEntity setStatus(Integer status) { + this.status = status; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenNotificationStatusEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenNotificationStatusEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenNotificationStatusEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenNotificationStatusEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenNotificationStatusEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[3]; + keyValues[0] = this.targetId; + keyValues[1] = this.type; + keyValues[2] = this.userId; + return keyValues; + } + /** + * Set key values + * @param targetId ターゲットのID + * @param type 種類 + * @param userId 登録者 + */ + public void setKeyValues(Long targetId, Integer type, Integer userId) { + this.targetId = targetId; + this.type = type; + this.userId = userId; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenNotificationStatusEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("targetId = ").append(targetId).append("\n"); + builder.append("type = ").append(type).append("\n"); + builder.append("userId = ").append(userId).append("\n"); + builder.append("status = ").append(status).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.type, convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.type, convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.targetId, convLabelName("Target Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.status, convLabelName("Status")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("type"), convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("type"), convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("targetId"), convLabelName("Target Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("status"), convLabelName("Status")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenPointKnowledgeHistoriesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenPointKnowledgeHistoriesEntity.java new file mode 100644 index 000000000..d3ffc698f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenPointKnowledgeHistoriesEntity.java @@ -0,0 +1,506 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * ナレッジのポイント獲得履歴 + */ +@DI(instance = Instance.Prototype) +public class GenPointKnowledgeHistoriesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenPointKnowledgeHistoriesEntity get() { + return Container.getComp(GenPointKnowledgeHistoriesEntity.class); + } + + /** + * Constructor. + */ + public GenPointKnowledgeHistoriesEntity() { + super(); + } + + /** + * Constructor + * @param historyNo 履歴番号 + * @param knowledgeId ナレッジID + */ + + public GenPointKnowledgeHistoriesEntity(Long historyNo, Long knowledgeId) { + super(); + this.historyNo = historyNo; + this.knowledgeId = knowledgeId; + } + /** ナレッジID */ + private Long knowledgeId; + /** 履歴番号 */ + private Long historyNo; + /** アクティビティ番号 */ + private Long activityNo; + /** 獲得のタイプ */ + private Integer type; + /** 獲得ポイント */ + private Integer point; + /** 獲得前ポイント */ + private Integer beforeTotal; + /** トータルポイント */ + private Integer total; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get ナレッジID. + * @return ナレッジID + */ + public Long getKnowledgeId() { + return this.knowledgeId; + } + /** + * Set ナレッジID. + * @param knowledgeId ナレッジID + * @return this object */ + public GenPointKnowledgeHistoriesEntity setKnowledgeId(Long knowledgeId) { + this.knowledgeId = knowledgeId; + return this; + } + + /** + * Get 履歴番号. + * @return 履歴番号 + */ + public Long getHistoryNo() { + return this.historyNo; + } + /** + * Set 履歴番号. + * @param historyNo 履歴番号 + * @return this object */ + public GenPointKnowledgeHistoriesEntity setHistoryNo(Long historyNo) { + this.historyNo = historyNo; + return this; + } + + /** + * Get アクティビティ番号. + * @return アクティビティ番号 + */ + public Long getActivityNo() { + return this.activityNo; + } + /** + * Set アクティビティ番号. + * @param activityNo アクティビティ番号 + * @return this object */ + public GenPointKnowledgeHistoriesEntity setActivityNo(Long activityNo) { + this.activityNo = activityNo; + return this; + } + + /** + * Get 獲得のタイプ. + * @return 獲得のタイプ + */ + public Integer getType() { + return this.type; + } + /** + * Set 獲得のタイプ. + * @param type 獲得のタイプ + * @return this object */ + public GenPointKnowledgeHistoriesEntity setType(Integer type) { + this.type = type; + return this; + } + + /** + * Get 獲得ポイント. + * @return 獲得ポイント + */ + public Integer getPoint() { + return this.point; + } + /** + * Set 獲得ポイント. + * @param point 獲得ポイント + * @return this object */ + public GenPointKnowledgeHistoriesEntity setPoint(Integer point) { + this.point = point; + return this; + } + + /** + * Get 獲得前ポイント. + * @return 獲得前ポイント + */ + public Integer getBeforeTotal() { + return this.beforeTotal; + } + /** + * Set 獲得前ポイント. + * @param beforeTotal 獲得前ポイント + * @return this object */ + public GenPointKnowledgeHistoriesEntity setBeforeTotal(Integer beforeTotal) { + this.beforeTotal = beforeTotal; + return this; + } + + /** + * Get トータルポイント. + * @return トータルポイント + */ + public Integer getTotal() { + return this.total; + } + /** + * Set トータルポイント. + * @param total トータルポイント + * @return this object */ + public GenPointKnowledgeHistoriesEntity setTotal(Integer total) { + this.total = total; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenPointKnowledgeHistoriesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenPointKnowledgeHistoriesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenPointKnowledgeHistoriesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenPointKnowledgeHistoriesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenPointKnowledgeHistoriesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[2]; + keyValues[0] = this.historyNo; + keyValues[1] = this.knowledgeId; + return keyValues; + } + /** + * Set key values + * @param historyNo 履歴番号 + * @param knowledgeId ナレッジID + */ + public void setKeyValues(Long historyNo, Long knowledgeId) { + this.historyNo = historyNo; + this.knowledgeId = knowledgeId; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenPointKnowledgeHistoriesEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("historyNo = ").append(historyNo).append("\n"); + builder.append("knowledgeId = ").append(knowledgeId).append("\n"); + builder.append("activityNo = ").append(activityNo).append("\n"); + builder.append("type = ").append(type).append("\n"); + builder.append("point = ").append(point).append("\n"); + builder.append("beforeTotal = ").append(beforeTotal).append("\n"); + builder.append("total = ").append(total).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.knowledgeId, convLabelName("Knowledge Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.historyNo, convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.activityNo, convLabelName("Activity No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.type, convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.type, convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.beforeTotal, convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.beforeTotal, convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.total, convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.total, convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("knowledgeId"), convLabelName("Knowledge Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("historyNo"), convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("activityNo"), convLabelName("Activity No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("type"), convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("type"), convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("beforeTotal"), convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("beforeTotal"), convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("total"), convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("total"), convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenPointUserHistoriesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenPointUserHistoriesEntity.java new file mode 100644 index 000000000..800244f08 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenPointUserHistoriesEntity.java @@ -0,0 +1,516 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * ユーザのポイント獲得履歴 + */ +@DI(instance = Instance.Prototype) +public class GenPointUserHistoriesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenPointUserHistoriesEntity get() { + return Container.getComp(GenPointUserHistoriesEntity.class); + } + + /** + * Constructor. + */ + public GenPointUserHistoriesEntity() { + super(); + } + + /** + * Constructor + * @param historyNo 履歴番号 + * @param userId ユーザID + */ + + public GenPointUserHistoriesEntity(Long historyNo, Integer userId) { + super(); + this.historyNo = historyNo; + this.userId = userId; + } + /** ユーザID */ + private Integer userId; + /** 履歴番号 */ + private Long historyNo; + /** アクティビティ番号 */ + private Long activityNo; + /** 獲得のタイプ */ + private Integer type; + /** 獲得ポイント */ + private Integer point; + /** 獲得前ポイント */ + private Integer beforeTotal; + /** トータルポイント */ + private Integer total; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get ユーザID. + * @return ユーザID + */ + public Integer getUserId() { + return this.userId; + } + /** + * Set ユーザID. + * @param userId ユーザID + * @return this object */ + public GenPointUserHistoriesEntity setUserId(Integer userId) { + this.userId = userId; + return this; + } + + /** + * Get 履歴番号. + * @return 履歴番号 + */ + public Long getHistoryNo() { + return this.historyNo; + } + /** + * Set 履歴番号. + * @param historyNo 履歴番号 + * @return this object */ + public GenPointUserHistoriesEntity setHistoryNo(Long historyNo) { + this.historyNo = historyNo; + return this; + } + + /** + * Get アクティビティ番号. + * @return アクティビティ番号 + */ + public Long getActivityNo() { + return this.activityNo; + } + /** + * Set アクティビティ番号. + * @param activityNo アクティビティ番号 + * @return this object */ + public GenPointUserHistoriesEntity setActivityNo(Long activityNo) { + this.activityNo = activityNo; + return this; + } + + /** + * Get 獲得のタイプ. + * @return 獲得のタイプ + */ + public Integer getType() { + return this.type; + } + /** + * Set 獲得のタイプ. + * @param type 獲得のタイプ + * @return this object */ + public GenPointUserHistoriesEntity setType(Integer type) { + this.type = type; + return this; + } + + /** + * Get 獲得ポイント. + * @return 獲得ポイント + */ + public Integer getPoint() { + return this.point; + } + /** + * Set 獲得ポイント. + * @param point 獲得ポイント + * @return this object */ + public GenPointUserHistoriesEntity setPoint(Integer point) { + this.point = point; + return this; + } + + /** + * Get 獲得前ポイント. + * @return 獲得前ポイント + */ + public Integer getBeforeTotal() { + return this.beforeTotal; + } + /** + * Set 獲得前ポイント. + * @param beforeTotal 獲得前ポイント + * @return this object */ + public GenPointUserHistoriesEntity setBeforeTotal(Integer beforeTotal) { + this.beforeTotal = beforeTotal; + return this; + } + + /** + * Get トータルポイント. + * @return トータルポイント + */ + public Integer getTotal() { + return this.total; + } + /** + * Set トータルポイント. + * @param total トータルポイント + * @return this object */ + public GenPointUserHistoriesEntity setTotal(Integer total) { + this.total = total; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenPointUserHistoriesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenPointUserHistoriesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenPointUserHistoriesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenPointUserHistoriesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenPointUserHistoriesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[2]; + keyValues[0] = this.historyNo; + keyValues[1] = this.userId; + return keyValues; + } + /** + * Set key values + * @param historyNo 履歴番号 + * @param userId ユーザID + */ + public void setKeyValues(Long historyNo, Integer userId) { + this.historyNo = historyNo; + this.userId = userId; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenPointUserHistoriesEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("historyNo = ").append(historyNo).append("\n"); + builder.append("userId = ").append(userId).append("\n"); + builder.append("activityNo = ").append(activityNo).append("\n"); + builder.append("type = ").append(type).append("\n"); + builder.append("point = ").append(point).append("\n"); + builder.append("beforeTotal = ").append(beforeTotal).append("\n"); + builder.append("total = ").append(total).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.historyNo, convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.activityNo, convLabelName("Activity No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.type, convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.type, convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.point, convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.beforeTotal, convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.beforeTotal, convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.total, convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.total, convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("historyNo"), convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("activityNo"), convLabelName("Activity No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("type"), convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("type"), convLabelName("Type")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("point"), convLabelName("Point")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("beforeTotal"), convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("beforeTotal"), convLabelName("Before Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("total"), convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("total"), convLabelName("Total")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateItemsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateItemsEntity.java index b5d0d95c5..6494ff8e7 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateItemsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateItemsEntity.java @@ -61,6 +61,8 @@ public GenTemplateItemsEntity(Integer itemNo, Integer typeId) { private Integer itemType; /** 説明 */ private String description; + /** 初期値 */ + private String initialValue; /** 登録ユーザ */ private Integer insertUser; /** 登録日時 */ @@ -152,6 +154,22 @@ public GenTemplateItemsEntity setDescription(String description) { return this; } + /** + * Get 初期値. + * @return 初期値 + */ + public String getInitialValue() { + return this.initialValue; + } + /** + * Set 初期値. + * @param initialValue 初期値 + * @return this object */ + public GenTemplateItemsEntity setInitialValue(String initialValue) { + this.initialValue = initialValue; + return this; + } + /** * Get 登録ユーザ. * @return 登録ユーザ @@ -288,6 +306,7 @@ public String toString() { builder.append("itemName = ").append(itemName).append("\n"); builder.append("itemType = ").append(itemType).append("\n"); builder.append("description = ").append(description).append("\n"); + builder.append("initialValue = ").append(initialValue).append("\n"); builder.append("insertUser = ").append(insertUser).append("\n"); builder.append("insertDatetime = ").append(insertDatetime).append("\n"); builder.append("updateUser = ").append(updateUser).append("\n"); diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateMastersEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateMastersEntity.java index 97bbcb93c..fe0842458 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateMastersEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenTemplateMastersEntity.java @@ -57,6 +57,8 @@ public GenTemplateMastersEntity(Integer typeId) { private String typeIcon; /** 説明 */ private String description; + /** 本文の初期値 */ + private String initialValue; /** 登録ユーザ */ private Integer insertUser; /** 登録日時 */ @@ -132,6 +134,22 @@ public GenTemplateMastersEntity setDescription(String description) { return this; } + /** + * Get 本文の初期値. + * @return 本文の初期値 + */ + public String getInitialValue() { + return this.initialValue; + } + /** + * Set 本文の初期値. + * @param initialValue 本文の初期値 + * @return this object */ + public GenTemplateMastersEntity setInitialValue(String initialValue) { + this.initialValue = initialValue; + return this; + } + /** * Get 登録ユーザ. * @return 登録ユーザ @@ -264,6 +282,7 @@ public String toString() { builder.append("typeName = ").append(typeName).append("\n"); builder.append("typeIcon = ").append(typeIcon).append("\n"); builder.append("description = ").append(description).append("\n"); + builder.append("initialValue = ").append(initialValue).append("\n"); builder.append("insertUser = ").append(insertUser).append("\n"); builder.append("insertDatetime = ").append(insertDatetime).append("\n"); builder.append("updateUser = ").append(updateUser).append("\n"); diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenUserBadgesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenUserBadgesEntity.java new file mode 100644 index 000000000..fbabbd8ee --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenUserBadgesEntity.java @@ -0,0 +1,341 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * ユーザの称号 + */ +@DI(instance = Instance.Prototype) +public class GenUserBadgesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenUserBadgesEntity get() { + return Container.getComp(GenUserBadgesEntity.class); + } + + /** + * Constructor. + */ + public GenUserBadgesEntity() { + super(); + } + + /** + * Constructor + * @param no 番号 + * @param userId ユーザID + */ + + public GenUserBadgesEntity(Integer no, Integer userId) { + super(); + this.no = no; + this.userId = userId; + } + /** ユーザID */ + private Integer userId; + /** 番号 */ + private Integer no; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get ユーザID. + * @return ユーザID + */ + public Integer getUserId() { + return this.userId; + } + /** + * Set ユーザID. + * @param userId ユーザID + * @return this object */ + public GenUserBadgesEntity setUserId(Integer userId) { + this.userId = userId; + return this; + } + + /** + * Get 番号. + * @return 番号 + */ + public Integer getNo() { + return this.no; + } + /** + * Set 番号. + * @param no 番号 + * @return this object */ + public GenUserBadgesEntity setNo(Integer no) { + this.no = no; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenUserBadgesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenUserBadgesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenUserBadgesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenUserBadgesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenUserBadgesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[2]; + keyValues[0] = this.no; + keyValues[1] = this.userId; + return keyValues; + } + /** + * Set key values + * @param no 番号 + * @param userId ユーザID + */ + public void setKeyValues(Integer no, Integer userId) { + this.no = no; + this.userId = userId; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenUserBadgesEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("no = ").append(no).append("\n"); + builder.append("userId = ").append(userId).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.no, convLabelName("No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.no, convLabelName("No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("no"), convLabelName("No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("no"), convLabelName("No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/filter/ApiFilter.java b/src/main/java/org/support/project/knowledge/filter/ApiFilter.java index 542886f6f..c168bacd2 100644 --- a/src/main/java/org/support/project/knowledge/filter/ApiFilter.java +++ b/src/main/java/org/support/project/knowledge/filter/ApiFilter.java @@ -14,16 +14,17 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.StringUtils; import org.support.project.di.Container; import org.support.project.knowledge.dao.TokensDao; import org.support.project.knowledge.entity.TokensEntity; +import org.support.project.knowledge.logic.KnowledgeAuthenticationLogic; import org.support.project.web.bean.LoginedUser; import org.support.project.web.common.HttpStatus; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.UsersEntity; import org.support.project.web.logic.AuthenticationLogic; -import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl; import org.support.project.web.wrapper.HttpServletRequestWrapper; public class ApiFilter implements Filter { @@ -54,7 +55,7 @@ public void destroy() { @Override public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) throws IOException, ServletException { - AuthenticationLogic authenticationLogic = (AuthenticationLogic) Container.getComp(DefaultAuthenticationLogicImpl.class); + AuthenticationLogic authenticationLogic = (AuthenticationLogic) Container.getComp(KnowledgeAuthenticationLogic.class); HttpServletRequest req_origin = (HttpServletRequest) servletrequest; HttpServletRequestWrapper req = new HttpServletRequestWrapper((HttpServletRequest) req_origin, authenticationLogic); HttpServletResponse res = (HttpServletResponse) servletresponse; @@ -90,7 +91,7 @@ public void doFilter(ServletRequest servletrequest, ServletResponse servletrespo res.sendError(HttpStatus.SC_403_FORBIDDEN); return; } - Date now = new Date(); + Date now = DateUtils.now(); if (now.getTime() > tokensEntity.getExpires().getTime()) { res.sendError(HttpStatus.SC_403_FORBIDDEN); return; @@ -104,7 +105,7 @@ public void doFilter(ServletRequest servletrequest, ServletResponse servletrespo return; } // 毎回セッションを生成して登録する(毎回なので少し重いかも) - authenticationLogic.setSession(user.getUserKey(), req); + authenticationLogic.setSession(user.getUserKey(), req, res); // APIの実際の処理を実施 filterchain.doFilter(req, res); diff --git a/src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java b/src/main/java/org/support/project/knowledge/filter/CloseAbleAuthenticationFilter.java similarity index 80% rename from src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java rename to src/main/java/org/support/project/knowledge/filter/CloseAbleAuthenticationFilter.java index 3db92d97a..93eea4d81 100644 --- a/src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java +++ b/src/main/java/org/support/project/knowledge/filter/CloseAbleAuthenticationFilter.java @@ -1,4 +1,4 @@ -package org.support.project.knowledge.listener; +package org.support.project.knowledge.filter; import java.io.IOException; import java.util.regex.Matcher; @@ -16,14 +16,17 @@ import org.support.project.di.Container; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.config.UserConfig; +import org.support.project.knowledge.logic.AccountLogic; +import org.support.project.knowledge.logic.KnowledgeAuthenticationLogic; import org.support.project.knowledge.logic.SystemConfigLogic; +import org.support.project.knowledge.vo.UserConfigs; import org.support.project.web.common.HttpStatus; import org.support.project.web.common.HttpUtil; import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.filter.AuthenticationFilter; import org.support.project.web.logic.AuthenticationLogic; -import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl; public class CloseAbleAuthenticationFilter extends AuthenticationFilter { @@ -62,9 +65,22 @@ public void doFilter(ServletRequest servletrequest, ServletResponse servletrespo if (SystemConfigLogic.get().isClose()) { HttpServletRequest req = (HttpServletRequest) servletrequest; HttpServletResponse res = (HttpServletResponse) servletresponse; + + // ブラウザから必ず送られてくるCookie値でユーザ設定情報を作成 + UserConfigs userConfig = new UserConfigs(); + String timezone = HttpUtil.getCookie(req, AccountLogic.get().getCookieKeyTimezone()); + if (StringUtils.isNotEmpty(timezone)) { + userConfig.setTimezone(timezone); + } + String offset = HttpUtil.getCookie(req, AccountLogic.get().getCookieKeyTimezoneOffset()); + if (StringUtils.isInteger(offset)) { + userConfig.setTimezoneOffset(Integer.parseInt(offset)); + } + req.setAttribute(UserConfig.REQUEST_USER_CONFIG_KEY, userConfig); + try { if (!isLogin(req)) { - AuthenticationLogic logic = Container.getComp(DefaultAuthenticationLogicImpl.class); + AuthenticationLogic logic = Container.getComp(KnowledgeAuthenticationLogic.class); logic.cookieLogin(req, res); } diff --git a/src/main/java/org/support/project/knowledge/filter/MaintenanceModeFilter.java b/src/main/java/org/support/project/knowledge/filter/MaintenanceModeFilter.java new file mode 100644 index 000000000..3e704f39c --- /dev/null +++ b/src/main/java/org/support/project/knowledge/filter/MaintenanceModeFilter.java @@ -0,0 +1,89 @@ +package org.support.project.knowledge.filter; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.support.project.knowledge.config.AppConfig; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.common.HttpUtil; +import org.support.project.web.config.CommonWebParameter; +import org.support.project.web.dao.SystemsDao; +import org.support.project.web.entity.SystemsEntity; + +public class MaintenanceModeFilter implements Filter { + + private Pattern pattern = Pattern.compile("^/bower|^/images|^/css|^/js|^/favicon.ico|^/lang|css$|js$|jpg$|jpeg$|gif$|png$|ico$|html$"); + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig config) throws ServletException { + } + + @Override + public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) + throws IOException, ServletException { + HttpServletRequest req = (HttpServletRequest) servletrequest; + HttpServletResponse res = (HttpServletResponse) servletresponse; + + StringBuilder pathBuilder = new StringBuilder(); + pathBuilder.append(req.getServletPath()); + if (req.getPathInfo() != null && req.getPathInfo().length() > 0) { + pathBuilder.append(req.getPathInfo()); + } + String path = pathBuilder.toString(); + + if (AppConfig.get().isMaintenanceMode()) { + // アクセス遮断の対象外のものは、普通にアクセス可能 + Matcher matcher = pattern.matcher(path); + if (matcher.find()) { + // 対象外なのでスルー + filterchain.doFilter(servletrequest, servletresponse); + return; + } + + // メンテナンスモード中にして、一般のユーザはアクセスできないようにする + LoginedUser user = (LoginedUser) req.getSession().getAttribute(CommonWebParameter.LOGIN_USER_INFO_SESSION_KEY); + if (user != null && user.isAdmin()) { + // 管理者 + if (path.equals("/protect.migrate")) { + SystemsEntity entity = SystemsDao.get().selectOnKey(AppConfig.get().getSystemName()); + if (entity != null) { + req.setAttribute("db_version", entity.getVersion()); + } + HttpUtil.forward(res, req, "/WEB-INF/views/commons/migrate.jsp"); + return; + } else if (path.equals("/migrate")) { + // マイグレーションのWebSocketパス + filterchain.doFilter(servletrequest, servletresponse); + return; + } + } + HttpUtil.forward(res, req, "/WEB-INF/views/commons/maintenance.jsp"); + return; + } else { + if (path.equals("/protect.migrate")) { + SystemsEntity entity = SystemsDao.get().selectOnKey(AppConfig.get().getSystemName()); + if (entity != null) { + req.setAttribute("db_version", entity.getVersion()); + } + HttpUtil.forward(res, req, "/WEB-INF/views/commons/migrate.jsp"); + return; + } + filterchain.doFilter(servletrequest, servletresponse); + } + } + +} diff --git a/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java b/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java index f37451b91..1cfc758d8 100644 --- a/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java +++ b/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java @@ -72,6 +72,7 @@ public void writeIndex(IndexingValue indexingValue) throws Exception { try { writer = new IndexWriter(dir, iwc); addDoc(writer, indexingValue); + writer.commit(); } finally { if (writer != null) { writer.close(); diff --git a/src/main/java/org/support/project/knowledge/listener/CronListener.java b/src/main/java/org/support/project/knowledge/listener/CronListener.java index 4ff9f14f5..e6685fbd3 100644 --- a/src/main/java/org/support/project/knowledge/listener/CronListener.java +++ b/src/main/java/org/support/project/knowledge/listener/CronListener.java @@ -45,6 +45,10 @@ public void contextInitialized(final ServletContextEvent sce) { fileClearfuture = service.scheduleAtFixedRate(new Runnable() { @Override public void run() { + if (AppConfig.get().isMaintenanceMode()) { + LOG.debug("This service is maintenance mode now."); + return; + } LOG.trace("called. [fileClearfuture]"); // Java を別のVMで実行(添付ファイルの定期的なクリア) JavaJob job = new JavaJob(); @@ -73,6 +77,10 @@ public void run() { parsefuture = service.scheduleAtFixedRate(new Runnable() { @Override public void run() { + if (AppConfig.get().isMaintenanceMode()) { + LOG.debug("This service is maintenance mode now."); + return; + } LOG.trace("called. [parsefuture]"); // 添付ファイルの中身を抽出し検索可能にする JavaJob job = new JavaJob(); @@ -101,6 +109,10 @@ public void run() { mailfuture = service.scheduleAtFixedRate(new Runnable() { @Override public void run() { + if (AppConfig.get().isMaintenanceMode()) { + LOG.debug("This service is maintenance mode now."); + return; + } LOG.trace("called. [mailfuture]"); // メール送信 JavaJob job = new JavaJob(); @@ -129,6 +141,10 @@ public void run() { webhookfuture = service.scheduleAtFixedRate(new Runnable() { @Override public void run() { + if (AppConfig.get().isMaintenanceMode()) { + LOG.debug("This service is maintenance mode now."); + return; + } LOG.trace("called. [webhookfuture]"); // Webhook JavaJob job = new JavaJob(); @@ -157,6 +173,10 @@ public void run() { mailHookfuture = service.scheduleAtFixedRate(new Runnable() { @Override public void run() { + if (AppConfig.get().isMaintenanceMode()) { + LOG.debug("This service is maintenance mode now."); + return; + } LOG.trace("called. [mailHookfuture]"); // メールからの投稿用のメールの読み込み JavaJob job = new JavaJob(); @@ -185,6 +205,10 @@ public void run() { notifyfuture = service.scheduleAtFixedRate(new Runnable() { @Override public void run() { + if (AppConfig.get().isMaintenanceMode()) { + LOG.debug("This service is maintenance mode now."); + return; + } LOG.trace("called. [notifyfuture]"); // Java を別のVMで実行(添付ファイルの中身を抽出し検索可能にする) JavaJob job = new JavaJob(); diff --git a/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java b/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java index e22962035..e7355ef2e 100644 --- a/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java +++ b/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java @@ -11,7 +11,6 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.util.StringUtils; import org.support.project.knowledge.config.AppConfig; -import org.support.project.knowledge.config.SystemConfig; public class GlobalInitializationListener implements ServletContextListener { private static final Log LOG = LogFactory.getLog(GlobalInitializationListener.class); diff --git a/src/main/java/org/support/project/knowledge/logic/AccountLogic.java b/src/main/java/org/support/project/knowledge/logic/AccountLogic.java index 81b4b4e62..515a7b619 100644 --- a/src/main/java/org/support/project/knowledge/logic/AccountLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/AccountLogic.java @@ -3,7 +3,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.UUID; @@ -19,6 +18,8 @@ import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.UserConfig; import org.support.project.knowledge.dao.AccountImagesDao; import org.support.project.knowledge.entity.AccountImagesEntity; import org.support.project.knowledge.vo.UploadFile; @@ -26,20 +27,62 @@ import org.support.project.web.dao.ConfirmMailChangesDao; import org.support.project.web.dao.GroupsDao; import org.support.project.web.dao.RolesDao; +import org.support.project.web.dao.UserConfigsDao; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.ConfirmMailChangesEntity; import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.RolesEntity; +import org.support.project.web.entity.UserConfigsEntity; import org.support.project.web.entity.UsersEntity; @DI(instance = Instance.Singleton) public class AccountLogic { /** ログ */ private static final Log LOG = LogFactory.getLog(AccountLogic.class); - public static AccountLogic get() { return Container.getComp(AccountLogic.class); } + + private String cookieKeyTimezone = ""; + private String cookieKeyTimezoneOffset = ""; + private String cookieKeyThema = ""; + private String cookieKeyHighlight = ""; + /** + * @return the cookie_key_timezone + */ + public String getCookieKeyTimezone() { + if (StringUtils.isEmpty(cookieKeyTimezone)) { + cookieKeyTimezone = AppConfig.get().getSystemName() + "_" + UserConfig.TIMEZONE; + } + return cookieKeyTimezone; + } + /** + * @return the cookie_key_timezone_offset + */ + public String getCookieKeyTimezoneOffset() { + if (StringUtils.isEmpty(cookieKeyTimezoneOffset)) { + cookieKeyTimezoneOffset = AppConfig.get().getSystemName() + "_" + UserConfig.TIME_ZONE_OFFSET; + } + return cookieKeyTimezoneOffset; + } + /** + * @return the cookie_key_thema + */ + public String getCookieKeyThema() { + if (StringUtils.isEmpty(cookieKeyThema)) { + cookieKeyThema = AppConfig.get().getSystemName() + "_" + UserConfig.THEMA; + } + return cookieKeyThema; + } + /** + * @return the cookie_key_highlight + */ + public String getCookieKeyHighlight() { + if (StringUtils.isEmpty(cookieKeyHighlight)) { + cookieKeyHighlight = AppConfig.get().getSystemName() + "_" + UserConfig.HIGHLIGHT; + } + return cookieKeyHighlight; + } /** * アイコンの保存 @@ -97,7 +140,7 @@ private UploadFile convUploadFile(String context, AccountImagesEntity entity) { UploadFile file = new UploadFile(); file.setFileNo(new Long(entity.getUserId())); file.setUrl(context + "/open.account/icon/" + entity.getUserId()); - file.setThumbnailUrl(context + "/open.account/icon/" + entity.getUserId() + "?t=" + new Date().getTime()); + file.setThumbnailUrl(context + "/open.account/icon/" + entity.getUserId() + "?t=" + DateUtils.now().getTime()); file.setName(entity.getFileName()); file.setType("-"); file.setSize(entity.getFileSize()); @@ -159,7 +202,7 @@ private String idGen(String label) { StringBuilder builder = new StringBuilder(); builder.append(label); builder.append("-"); - builder.append(DateUtils.getTransferDateFormat().format(new Date())); + builder.append(DateUtils.getTransferDateFormat().format(DateUtils.now())); builder.append("-"); builder.append(UUID.randomUUID().toString()); builder.append("-"); @@ -237,4 +280,58 @@ public LoginedUser createLoginUser(String userKey) { return loginedUser; } + /** + * ユーザのポイント取得 + * @param user ユーザ + * @return + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public int getPoint(int user) { + UserConfigsEntity config = UserConfigsDao.get().selectOnKey(UserConfig.POINT, AppConfig.get().getSystemName(), user); + if (config == null) { + config = new UserConfigsEntity(UserConfig.POINT, AppConfig.get().getSystemName(), user); + config.setConfigValue("0"); + } + if (!StringUtils.isInteger(config.getConfigValue())) { + config.setConfigValue("0"); + } + int now = Integer.parseInt(config.getConfigValue()); + return now; + } + + /** + * ユーザの設定を取得 + * @param user ユーザ + * @param configKey 設定キー + * @return 設定値 + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public String getConfig(int user, String configKey) { + UserConfigsEntity config = UserConfigsDao.get().selectOnKey(configKey, AppConfig.get().getSystemName(), user); + if (config == null) { + return ""; + } + return config.getConfigValue(); + } + /** + * ユーザの設定を取得 + * @param user ユーザ + * @param configKey 設定キー + * @return 設定値 + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void setConfig(int user, String configKey, String configValue) { + UserConfigsEntity config = UserConfigsDao.get().selectOnKey(configKey, AppConfig.get().getSystemName(), user); + if (config == null) { + config = new UserConfigsEntity(configKey, AppConfig.get().getSystemName(), user); + } + config.setConfigValue(configValue); + UserConfigsDao.get().save(config); + } + + + + + + } diff --git a/src/main/java/org/support/project/knowledge/logic/AggregateLogic.java b/src/main/java/org/support/project/knowledge/logic/AggregateLogic.java new file mode 100644 index 000000000..84b20d31c --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/AggregateLogic.java @@ -0,0 +1,472 @@ +package org.support.project.knowledge.logic; + +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.UserConfig; +import org.support.project.knowledge.dao.ActivitiesDao; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.LikeCommentsDao; +import org.support.project.knowledge.dao.LikesDao; +import org.support.project.knowledge.dao.ParticipantsDao; +import org.support.project.knowledge.dao.PointKnowledgeHistoriesDao; +import org.support.project.knowledge.dao.PointUserHistoriesDao; +import org.support.project.knowledge.dao.StockKnowledgesDao; +import org.support.project.knowledge.dao.SurveyAnswersDao; +import org.support.project.knowledge.dao.ViewHistoriesDao; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.LikeCommentsEntity; +import org.support.project.knowledge.entity.LikesEntity; +import org.support.project.knowledge.entity.ParticipantsEntity; +import org.support.project.knowledge.entity.PointUserHistoriesEntity; +import org.support.project.knowledge.entity.StockKnowledgesEntity; +import org.support.project.knowledge.entity.SurveyAnswersEntity; +import org.support.project.knowledge.entity.ViewHistoriesEntity; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; +import org.support.project.ormapping.config.Order; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.UserConfigsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.UsersEntity; + +@DI(instance = Instance.Prototype) +public class AggregateLogic { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AggregateLogic.class); + /** Get instance */ + public static AggregateLogic get() { + return Container.getComp(AggregateLogic.class); + } + + private static final int _WAIT = 100; + private int limit = 1; // 1件毎にコミットいれないと、別コネクションで取得して結果をクリアしてしまう? + private int calcTotal = 0; // トータルポイントの再計算に使う内部保持変数(シーケンシャルに1件づつ処理をすること) + private int processCount = 0; + + private void logging(String string) { + processCount++; + if (processCount % 100 == 0) { + LOG.info("\t During execution of the " + string + ". [count]" + processCount); + } + } + + /** + * 全て再集計 + * @throws Exception + */ + public void startAggregate() throws Exception { + // 参照回数を集計 + this.doSetViewCountToKnowledge(); + // ユーザについているポイントをクリア + this.clearUserPoint(); + // 既に登録済のActivityの履歴があればクリア + this.initActivities(); + // Knowledgeを登録したイベントによりポイントを集計 + this.doAddPointByKnowledge(); + // Knowledgeを参照したイベントによりポイントを集計 + this.doAddPointByKnowledgeShow(); + // Knowledgeにイイネを押したイベントによりポイント集計 + this.doAddPointByKnowledgeLike(); + // Knowledgeをストックイベントによりポイント集計 + this.doAddPointByKnowledgeStock(); + // Knowledgeのアンケートを回答したイベントによりポイント集計 + this.doAddPointByKnowledgeAnswer(); + // Knowledgeイベント参加したイベントによりポイント集計 + this.doAddPointByKnowledgeJoinEvent(); + // コメントを登録したイベントによりポイント集計 + this.doAddPointByCommentInsert(); + // コメントへのイイネイベントによりポイント集計 + this.doAddPointByCommentLike(); + + // ポイント集計は、今後は時系列になり問題は無いが、このマイグレーションの中では、時系列にはならんでいないので、履歴のトータルを再構築 + this.reCalcPointUserHistory(); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void initActivities() { + PointKnowledgeHistoriesDao.get().removeAll(); + PointUserHistoriesDao.get().removeAll(); + ActivitiesDao.get().removeAll(); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void doSetViewCountToKnowledge() throws InterruptedException { + LOG.info("Set view count to Knowledge"); + processCount = 0; + List knowledges; + int offset = 0; + do { + logging("Set view count to Knowledge"); + knowledges = doSetViewCountToKnowledge(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (knowledges.size() > 0); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void clearUserPoint() { + UserConfigsDao.get().removeAllUserConfig(AppConfig.get().getSystemName(), UserConfig.POINT); + } + + public void reCalcPointUserHistory() throws InterruptedException { + LOG.info("Recalc user cp"); + List list; + int offset = 0; + do { + list = reCalcPointUserHistory(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + private List reCalcPointUserHistory(int offset) throws InterruptedException { + List list; + list = UsersDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (UsersEntity item : list) { + processCount = 0; + LOG.info(" Recalculation total point. [user]" + item.getUserId()); + int offset2 = 0; + calcTotal = 0; // ユーザ毎にトータルポイントを初期化 + List histories; + do { + logging(" Recalculation... "); + histories = reCalcPointUserHistoryOnUser(item.getUserId(), offset2); + offset2 = offset2 + limit; + synchronized (this) { + wait(_WAIT); + } + } while (histories.size() > 0); + } + return list; + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + private List reCalcPointUserHistoryOnUser(Integer userId, int offset2) { + List list; + list = PointUserHistoriesDao.get().selectOnUser(userId, limit, offset2, Order.ASC); + for (PointUserHistoriesEntity item : list) { + item.setBeforeTotal(calcTotal); + calcTotal += item.getPoint(); + item.setTotal(calcTotal); // 日付毎に処理してトータルを再計算 + LOG.debug("\t" + DateUtils.getSimpleFormat().format(item.getInsertDatetime()) + " [total]" + calcTotal); + PointUserHistoriesDao.get().physicalUpdate(item); + } + return list; + } + + public void doAddPointByCommentLike() throws InterruptedException { + LOG.info("Aggregate point by comment like"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by comment like"); + list = doAddPointByCommentLike(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + private List doAddPointByCommentLike(int offset) { + List list; + list = LikeCommentsDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (LikeCommentsEntity item : list) { + CommentsEntity comment = CommentsDao.get().selectOnKey(item.getCommentNo()); + if (comment == null) { + LOG.debug(" comment [" + item.getCommentNo() + "] is not found. so skip add point by comment like."); + continue; + } + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by comment like."); + continue; + } + user.setLoginUser(account); + LOG.debug(" comment [" + item.getCommentNo() + "], knowledge [ " + comment.getKnowledgeId() + "]"); + ActivityLogic.get().processActivity(Activity.COMMENT_LIKE, user, item.getInsertDatetime(), comment); + } + return list; + } + + public void doAddPointByCommentInsert() throws InterruptedException { + LOG.info("Aggregate point by comment insert"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by comment insert"); + list = doAddPointByKnowledgeComment(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledgeComment(int offset) { + List list; + list = CommentsDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (CommentsEntity item : list) { + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by comment insert."); + continue; + } + user.setLoginUser(account); + LOG.debug(" comment [" + item.getCommentNo() + "], knowledge [ " + item.getKnowledgeId() + "]"); + ActivityLogic.get().processActivity(Activity.COMMENT_INSERT, user, item.getInsertDatetime(), item); + } + return list; + } + + public void doAddPointByKnowledgeJoinEvent() throws InterruptedException { + LOG.info("Aggregate point by knowledge join event"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by knowledge join event"); + list = doAddPointByKnowledgeJoinEvent(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledgeJoinEvent(int offset) { + List list; + list = ParticipantsDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (ParticipantsEntity item : list) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(item.getKnowledgeId()); + if (knowledge == null) { + LOG.debug(" knowledge [" + item.getKnowledgeId() + "] is not found. so skip add point by knowledge event."); + continue; + } + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by knowledge event."); + continue; + } + user.setLoginUser(account); + LOG.debug(" knowledge [" + knowledge.getKnowledgeId() + "] "); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_EVENT_ADD, user, item.getInsertDatetime(), knowledge); + } + return list; + } + + public void doAddPointByKnowledgeAnswer() throws InterruptedException { + LOG.info("Aggregate point by knowledge answer"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by knowledge answer"); + list = doAddPointByKnowledgeAnswer(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledgeAnswer(int offset) { + List list; + list = SurveyAnswersDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (SurveyAnswersEntity item : list) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(item.getKnowledgeId()); + if (knowledge == null) { + LOG.debug(" knowledge [" + item.getKnowledgeId() + "] is not found. so skip add point by knowledge survey answer."); + continue; + } + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by knowledge survey answer."); + continue; + } + user.setLoginUser(account); + LOG.debug(" knowledge [" + knowledge.getKnowledgeId() + "] "); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_ANSWER, user, item.getInsertDatetime(), knowledge); + } + return list; + } + + public void doAddPointByKnowledgeStock() throws InterruptedException { + LOG.info("Aggregate point by knowledge stock"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by knowledge stock"); + list = doAddPointByKnowledgeStock(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledgeStock(int offset) { + List list; + list = StockKnowledgesDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (StockKnowledgesEntity item : list) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(item.getKnowledgeId()); + if (knowledge == null) { + LOG.debug(" knowledge [" + item.getKnowledgeId() + "] is not found. so skip add point by knowledge stock."); + continue; + } + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by knowledge stock."); + continue; + } + user.setLoginUser(account); + LOG.debug(" knowledge [" + knowledge.getKnowledgeId() + "] "); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_STOCK, user, item.getInsertDatetime(), knowledge); + } + return list; + } + + public void doAddPointByKnowledgeLike() throws InterruptedException { + LOG.info("Aggregate point by knowledge like"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by knowledge like"); + list = doAddPointByKnowledgeLike(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledgeLike(int offset) { + List list; + list = LikesDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (LikesEntity item : list) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(item.getKnowledgeId()); + if (knowledge == null) { + LOG.debug(" knowledge [" + item.getKnowledgeId() + "] is not found. so skip add point by knowledge like."); + continue; + } + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by knowledge like."); + continue; + } + user.setLoginUser(account); + LOG.debug(" knowledge [" + knowledge.getKnowledgeId() + "] "); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_LIKE, user, item.getInsertDatetime(), knowledge); + } + return list; + } + + public void doAddPointByKnowledgeShow() throws InterruptedException { + LOG.info("Aggregate point by knowledge show"); + processCount = 0; + List list; + int offset = 0; + do { + logging("Aggregate point by knowledge show"); + list = doAddPointByKnowledgeShow(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (list.size() > 0); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledgeShow(int offset) { + List list; + list = ViewHistoriesDao.get().selectDistinctAllWidthPager(limit, offset); + for (ViewHistoriesEntity item : list) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(item.getKnowledgeId()); + if (knowledge == null) { + LOG.debug(" knowledge [" + item.getKnowledgeId() + "] is not found. so skip add point by knowledge show."); + continue; + } + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" event user [" + item.getInsertUser() + "] is not found. so skip add point by knowledge show."); + continue; + } + user.setLoginUser(account); + LOG.debug(" knowledge [" + knowledge.getKnowledgeId() + "] "); + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_SHOW, user, item.getInsertDatetime(), knowledge); + } + return list; + } + + public void doAddPointByKnowledge() throws InterruptedException { + LOG.info("Aggregate point by knowledge insert"); + processCount = 0; + List knowledges; + int offset = 0; + do { + logging("Aggregate point by knowledge insert"); + knowledges = doAddPointByKnowledge(offset); + offset = offset + limit; + synchronized (this) { + wait(_WAIT); + } + } while (knowledges.size() > 0); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doAddPointByKnowledge(int offset) { + List knowledges; + knowledges = KnowledgesDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (KnowledgesEntity item : knowledges) { + LoginedUser user = new LoginedUser(); + UsersEntity account = UsersDao.get().selectOnKey(item.getInsertUser()); + if (account == null) { + LOG.debug(" insert user [" + item.getInsertUser() + "] is not found. so skip add point by knowledge insert."); + continue; + } + user.setLoginUser(account); + LOG.debug(" knowledge [" + item.getKnowledgeId() + "] "); + ActivityLogic.get().processKnowledgeSaveActivity(user, item.getInsertDatetime(), item); + } + return knowledges; + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List doSetViewCountToKnowledge(int offset) { + List knowledges; + knowledges = KnowledgesDao.get().selectAllWidthPager(limit, offset, Order.ASC); + for (KnowledgesEntity knowledge : knowledges) { + long count = ViewHistoriesDao.get().selectCountOnKnowledgeId(knowledge.getKnowledgeId()); + KnowledgesDao.get().updateViewCount(count, knowledge.getKnowledgeId()); + //ついでにポイントも初期化 + KnowledgesDao.get().updatePoint(knowledge.getKnowledgeId(), 0); + LOG.debug(" knowledge [" + knowledge.getKnowledgeId() + "] is updated. view count : " + count); + } + return knowledges; + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java index 32c61491f..1b0804cd4 100644 --- a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java @@ -313,7 +313,7 @@ public void backupAndInitH2() throws IOException { AppConfig appConfig = AppConfig.get(); Path source = Paths.get(appConfig.getDatabasePath()); if (Files.exists(source)) { - Path target = Paths.get(appConfig.getBasePath() + "/db_" + DateUtils.getTransferDateFormat().format(new Date())); + Path target = Paths.get(appConfig.getBasePath() + "/db_" + DateUtils.getTransferDateFormat().format(DateUtils.now())); Files.move(source, target, StandardCopyOption.REPLACE_EXISTING); } } diff --git a/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java b/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java index 578c31201..09a5998f9 100644 --- a/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java @@ -44,7 +44,7 @@ public static DatabaseLogic get() { public FileInputStreamWithDeleteWrapper getData() throws IOException { AppConfig config = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); File tmpDir = new File(config.getTmpPath()); - String name = "knowledge-" + DateUtils.formatTransferDateTime(new Date()) + ".zip"; + String name = "knowledge-" + DateUtils.formatTransferDateTime(DateUtils.now()) + ".zip"; File tmp = new File(tmpDir, name); BufferedOutputStream output = null; @@ -81,7 +81,7 @@ public List restore(FileItem fileItem) throws IOException { List errors = new ArrayList(); AppConfig config = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); File tmpDir = new File(config.getTmpPath()); - String name = "knowledge-restore-" + DateUtils.formatTransferDateTime(new Date()) + ""; + String name = "knowledge-restore-" + DateUtils.formatTransferDateTime(DateUtils.now()) + ""; File tmp = new File(tmpDir, name); if (tmp.exists() && !tmp.isDirectory()) { errors.add(new ValidateError("knowledge.data.label.msg.fail")); diff --git a/src/main/java/org/support/project/knowledge/logic/EventsLogic.java b/src/main/java/org/support/project/knowledge/logic/EventsLogic.java index b1880df1d..6a232d4ea 100644 --- a/src/main/java/org/support/project/knowledge/logic/EventsLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/EventsLogic.java @@ -22,6 +22,10 @@ import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.ParticipantsEntity; +import org.support.project.knowledge.logic.notification.ParticipateChangeStatusForParticipantNotification; +import org.support.project.knowledge.logic.notification.ParticipateForParticipantNotification; +import org.support.project.knowledge.logic.notification.ParticipateForSponsorNotification; +import org.support.project.knowledge.logic.notification.ParticipateRemoveForSponsorNotification; import org.support.project.knowledge.vo.Participation; import org.support.project.knowledge.vo.Participations; import org.support.project.web.bean.LoginedUser; @@ -154,10 +158,9 @@ public Boolean participation(Long knowledgeId, Integer userId) { ParticipantsDao.get().insert(participant); // 開催者(=登録者)へメール通知 - MailLogic.get().notifyAddParticipateForSponsor(knowledgeId, userId, participant.getStatus()); - + ParticipateForSponsorNotification.get().notify(knowledgeId, userId, participant.getStatus()); // 参加者へメール通知 - MailLogic.get().notifyAddParticipateForParticipant(knowledgeId, userId, participant.getStatus()); + ParticipateForParticipantNotification.get().notify(knowledgeId, userId, participant.getStatus()); return participant.getStatus().intValue() == STATUS_PARTICIPATION; } @@ -177,8 +180,8 @@ public void removeParticipation(Long knowledgeId, Integer userId) { ParticipantsDao.get().physicalDelete(participant); // 物理的に削除 // 開催者(=登録者)へメール通知 - MailLogic.get().notifyRemoveParticipateForSponsor(knowledgeId, userId); - + ParticipateRemoveForSponsorNotification.get().notify(knowledgeId, userId, -1); + if (participant.getStatus().intValue() == STATUS_PARTICIPATION) { List participants = ParticipantsDao.get().selectParticipations(knowledgeId); for (int i = 0; i < participants.size(); i++) { @@ -189,7 +192,7 @@ public void removeParticipation(Long knowledgeId, Integer userId) { ParticipantsDao.get().update(entity); // キャンセル待ちが参加登録済になった参加者へメール通知 - MailLogic.get().notifyChangeParticipateStatusForParticipant(knowledgeId, p.getUserId()); + ParticipateChangeStatusForParticipantNotification.get().notify(knowledgeId, p.getUserId(), STATUS_PARTICIPATION); break; // キャンセル待ちの1件を本登録に変更 } diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeAuthenticationLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeAuthenticationLogic.java new file mode 100644 index 000000000..f37e1b1d2 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeAuthenticationLogic.java @@ -0,0 +1,70 @@ +package org.support.project.knowledge.logic; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.web.exception.AuthenticateException; +import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl; + +@DI(instance = Instance.Singleton) +public class KnowledgeAuthenticationLogic extends DefaultAuthenticationLogicImpl { + /** ログ */ + private static final Log LOG = LogFactory.getLog(DefaultAuthenticationLogicImpl.class); + + + @Override + public void setSession(String userId, HttpServletRequest request, HttpServletResponse response) throws AuthenticateException { + super.setSession(userId, request, response); + + /* TODO タイムゾーンなどのユーザ設定をDBに保持する。保持されていた場合は、そちらを有効にする。 + * UIでタイムゾーンを指定可能にする(現状はブラウザで自動判定している) + + LoginedUser loginedUser = getSession(request); + if (loginedUser == null) { + return; + } + + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + LOG.trace("Cookies"); + for (Cookie cookie : cookies) { + LOG.trace(cookie.getName()); + LOG.trace(cookie.getValue()); + if (AccountLogic.get().getCookieKeyTimezone().equals(cookie.getName())) { + String value = AccountLogic.get().getConfig(loginedUser.getUserId(), UserConfig.TIMEZONE); + if (StringUtils.isEmpty(value)) { + AccountLogic.get().setConfig(loginedUser.getUserId(), UserConfig.TIMEZONE, cookie.getValue()); + } else { + HttpUtil.setCookie(request, response, AccountLogic.get().getCookieKeyTimezone(), value); + } + } else if (AccountLogic.get().getCookieKeyTimezoneOffset().equals(cookie.getName())) { + String value = AccountLogic.get().getConfig(loginedUser.getUserId(), UserConfig.TIME_ZONE_OFFSET); + if (StringUtils.isEmpty(value)) { + AccountLogic.get().setConfig(loginedUser.getUserId(), UserConfig.TIME_ZONE_OFFSET, cookie.getValue()); + } else { + HttpUtil.setCookie(request, response, AccountLogic.get().getCookieKeyTimezoneOffset(), value); + } + } else if (AccountLogic.get().getCookieKeyThema().equals(cookie.getName())) { + String value = AccountLogic.get().getConfig(loginedUser.getUserId(), UserConfig.THEMA); + if (StringUtils.isEmpty(value)) { + AccountLogic.get().setConfig(loginedUser.getUserId(), UserConfig.THEMA, cookie.getValue()); + } else { + HttpUtil.setCookie(request, response, AccountLogic.get().getCookieKeyThema(), value); + } + } else if (AccountLogic.get().getCookieKeyHighlight().equals(cookie.getName())) { + String value = AccountLogic.get().getConfig(loginedUser.getUserId(), UserConfig.HIGHLIGHT); + if (StringUtils.isEmpty(value)) { + AccountLogic.get().setConfig(loginedUser.getUserId(), UserConfig.HIGHLIGHT, cookie.getValue()); + } else { + HttpUtil.setCookie(request, response, AccountLogic.get().getCookieKeyHighlight(), value); + } + } + } + } + */ + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java index 36564bb1d..16ac74371 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java @@ -50,6 +50,9 @@ private KnowledgeData conv(KnowledgeDetail data) throws InvalidParamException { KnowledgesEntity entity = new KnowledgesEntity(); PropertyUtil.copyPropertyValue(data, entity); + // 必須チェックエラーになるので、初期値をセット(更新時は、KnowledgeLogicのupdateの中でDBに保存されている値を保持するようにセットしなおしている) + entity.setPoint(0); + List errors = entity.validate(); if (errors != null && !errors.isEmpty()) { StringJoinBuilder builder = new StringJoinBuilder<>(); @@ -100,6 +103,9 @@ private KnowledgeData conv(KnowledgeDetail data) throws InvalidParamException { } private String convTargets(Target viewers) { + if (viewers == null) { + return ""; + } StringJoinBuilder builder = new StringJoinBuilder<>(); List groups = viewers.getGroups(); if (groups != null) { @@ -154,6 +160,10 @@ public void update(KnowledgeDetail data, LoginedUser loginedUser) throws Excepti } // 画面での登録と形をあわせる KnowledgeData knowledge = conv(data); + // APIからデータ更新した場合、つねに「更新した」と判定する + // TODO この辺の判定処理は、後で共有化すること(KnowledgeControlで、ロジックを実装しすぎている) + knowledge.setUpdateContent(true); + knowledge.setNotifyUpdate(true); KnowledgeLogic.get().update(knowledge, loginedUser); } diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index 1c6f1063c..ed229cda2 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -3,7 +3,6 @@ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -11,6 +10,7 @@ import org.support.project.aop.Aspect; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.HtmlUtils; import org.support.project.common.util.PropertyUtil; import org.support.project.common.util.StringJoinBuilder; @@ -20,6 +20,7 @@ import org.support.project.di.Instance; import org.support.project.knowledge.bat.FileParseBat; import org.support.project.knowledge.config.IndexType; +import org.support.project.knowledge.config.SystemConfig; import org.support.project.knowledge.dao.CommentsDao; import org.support.project.knowledge.dao.DraftItemValuesDao; import org.support.project.knowledge.dao.DraftKnowledgesDao; @@ -51,13 +52,14 @@ import org.support.project.knowledge.entity.KnowledgeTagsEntity; import org.support.project.knowledge.entity.KnowledgeUsersEntity; import org.support.project.knowledge.entity.KnowledgesEntity; -import org.support.project.knowledge.entity.LikesEntity; import org.support.project.knowledge.entity.StocksEntity; import org.support.project.knowledge.entity.TagsEntity; import org.support.project.knowledge.entity.TemplateItemsEntity; import org.support.project.knowledge.entity.TemplateMastersEntity; import org.support.project.knowledge.entity.ViewHistoriesEntity; import org.support.project.knowledge.indexer.IndexingValue; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; import org.support.project.knowledge.logic.hook.AfterSaveHook; import org.support.project.knowledge.logic.hook.BeforeSaveHook; import org.support.project.knowledge.logic.hook.HookFactory; @@ -217,6 +219,10 @@ public KnowledgesEntity insert(KnowledgeData data, LoginedUser loginedUser) thro for (AfterSaveHook afterSaveHook : afterSaveHooks) { afterSaveHook.afterSave(data, loginedUser); } + + // CPの処理 + ActivityLogic.get().processKnowledgeSaveActivity(loginedUser, DateUtils.now(), insertedEntity); + return insertedEntity; } @@ -239,6 +245,7 @@ public KnowledgesEntity update(KnowledgeData data, LoginedUser loginedUser) thro // ナレッッジを更新 data.getKnowledge().setNotifyStatus(db.getNotifyStatus()); // 通知フラグはDBの値を引き継ぐ + data.getKnowledge().setPoint(db.getPoint()); // ポイントもDBの値を引き継ぐ KnowledgesEntity updatedEntity = knowledgesDao.update(data.getKnowledge()); // ユーザのアクセス権を解除 knowledgeUsersDao.deleteOnKnowledgeId(updatedEntity.getKnowledgeId()); @@ -272,14 +279,21 @@ public KnowledgesEntity update(KnowledgeData data, LoginedUser loginedUser) thro if (data.isUpdateContent()) { // 履歴登録 insertHistory(updatedEntity); - // 通知 - NotifyLogic.get().notifyOnKnowledgeUpdate(updatedEntity); } else { // 更新ユーザ&更新日付を戻す updatedEntity.setUpdateUser(db.getUpdateUser()); updatedEntity.setUpdateDatetime(db.getUpdateDatetime()); knowledgesDao.physicalUpdate(updatedEntity); } + if (data.isNotifyUpdate()) { + // 通知 + NotifyLogic.get().notifyOnKnowledgeUpdate(updatedEntity); + } + if (data.isDonotUpdateTimeline()) { + // タイムラインの上に表示しないと明示的に指定があれば、全文検索エンジン上の更新日は更新しない(検索エンジンのインデックスでタイムラインを作っているため) + updatedEntity.setUpdateDatetime(db.getUpdateDatetime()); + } + // 全文検索エンジンへ登録 saveIndex(updatedEntity, data.getTags(), data.getViewers(), data.getTemplate(), updatedEntity.getInsertUser()); @@ -290,6 +304,10 @@ public KnowledgesEntity update(KnowledgeData data, LoginedUser loginedUser) thro for (AfterSaveHook afterSaveHook : afterSaveHooks) { afterSaveHook.afterSave(data, loginedUser); } + + // CP + ActivityLogic.get().processKnowledgeSaveActivity(loginedUser, DateUtils.now(), updatedEntity); + return updatedEntity; } @@ -1078,38 +1096,28 @@ public void deleteOnUser(Integer loginUserId) throws Exception { * @param knowledgeId * @param loginedUser */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void addViewHistory(Long knowledgeId, LoginedUser loginedUser) { ViewHistoriesDao historiesDao = ViewHistoriesDao.get(); ViewHistoriesEntity historiesEntity = new ViewHistoriesEntity(); historiesEntity.setKnowledgeId(knowledgeId); - historiesEntity.setViewDateTime(new Timestamp(new Date().getTime())); + historiesEntity.setViewDateTime(new Timestamp(DateUtils.now().getTime())); if (loginedUser != null) { historiesEntity.setInsertUser(loginedUser.getUserId()); + } else { + historiesEntity.setInsertUser(SystemConfig.SYSTEM_USER_ID); } historiesDao.insert(historiesEntity); - } - - /** - * いいね!を追加 - * - * @param knowledgeId - * @param loginedUser - * @return - */ - public Long addLike(Long knowledgeId, LoginedUser loginedUser) { - LikesDao likesDao = LikesDao.get(); - LikesEntity likesEntity = new LikesEntity(); - likesEntity.setKnowledgeId(knowledgeId); - likesDao.insert(likesEntity); - - updateKnowledgeExInfo(knowledgeId); - - Long count = likesDao.countOnKnowledgeId(knowledgeId); - - // 通知 - NotifyLogic.get().notifyOnKnowledgeLiked(knowledgeId, likesEntity); - - return count; + + KnowledgesEntity entity = KnowledgesDao.get().selectOnKey(knowledgeId); + if (entity != null) { + Long count = entity.getViewCount(); + if (count == null) { + count = new Long(0); + } + count = count + 1; + KnowledgesDao.get().updateViewCount(count, knowledgeId); + } } /** @@ -1183,6 +1191,9 @@ public CommentsEntity saveComment(Long knowledgeId, String comment, List f // 通知 NotifyLogic.get().notifyOnKnowledgeComment(knowledgeId, commentsEntity); + //ポイント + ActivityLogic.get().processActivity(Activity.COMMENT_INSERT, loginedUser, DateUtils.now(), commentsEntity); + return commentsEntity; } @@ -1401,7 +1412,7 @@ public boolean isEditor(LoginedUser loginedUser, KnowledgesEntity entity, List getPopularityKnowledges(LoginedUser loginedUser, int offset, int limit) { - long now = new Date().getTime(); + long now = DateUtils.now().getTime(); LOG.trace(now); long term = 1000L * 60L * 60L * 24L * 30L; @@ -1559,7 +1570,29 @@ public List selectAccessAbleKnowledge(String q, LoginedUser lo } return KnowledgesDao.get().selectAccessAbleKnowledgeOnIdPrefix(q, loginedUser, limit, offset); } - - + /** + * 参照済かどうかをセットする + * @param stocks + * @param loginedUser + */ + public void setViewed(List stocks, LoginedUser loginedUser) { + if (stocks == null) { + return; + } + if (loginedUser == null) { + // 未ログインユーザは、未読かんりしないので、全て既読にする + for (StockKnowledge knowledge : stocks) { + knowledge.setViewed(true); + } + return; + } + List knowledgeIds = ViewHistoriesDao.get().selectViewdKnowledgeIds(stocks, loginedUser.getUserId()); + for (StockKnowledge knowledge : stocks) { + if (knowledgeIds.contains(knowledge.getKnowledgeId())) { + knowledge.setViewed(true); + } + } + } + } diff --git a/src/main/java/org/support/project/knowledge/logic/LikeLogic.java b/src/main/java/org/support/project/knowledge/logic/LikeLogic.java new file mode 100644 index 000000000..d8a5e6267 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/LikeLogic.java @@ -0,0 +1,172 @@ +package org.support.project.knowledge.logic; + +import java.util.Locale; + +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; +import org.support.project.di.Container; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.LikeCommentsDao; +import org.support.project.knowledge.dao.LikesDao; +import org.support.project.knowledge.dao.NotificationStatusDao; +import org.support.project.knowledge.entity.LikeCommentsEntity; +import org.support.project.knowledge.entity.LikesEntity; +import org.support.project.knowledge.entity.NotificationStatusEntity; +import org.support.project.knowledge.logic.activity.Activity; +import org.support.project.knowledge.logic.activity.ActivityLogic; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.config.MessageStatus; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.exception.InvalidParamException; + +public class LikeLogic { + /** LOG */ + private static final Log LOG = LogFactory.getLog(LikeLogic.class); + /** Get instance */ + public static LikeLogic get() { + return Container.getComp(LikeLogic.class); + } + + private static final int TYPE_KNOWLEDGE = 1; + private static final int TYPE_COMMENT = 2; + + + /** + * イイネの重複チェックを行うかをシステム設定情報から取得 + * @return + */ + private boolean getCheckOfLike() { + boolean check = false; + SystemConfigsEntity config = SystemConfigsDao.get().selectOnKey(SystemConfig.LIKE_CONFIG, AppConfig.get().getSystemName()); + if (config != null) { + if (SystemConfig.LIKE_CONFIG_ONLY_ONE.equals(config.getConfigValue())) { + check = true; + } + } + return check; + } + + private boolean duplicateLike(Long knowledgeId, Integer userId) { + NotificationStatusEntity status = NotificationStatusDao.get().selectOnKey(knowledgeId, TYPE_KNOWLEDGE, userId); + if (status == null) { + return false; + } + return true; + } + private boolean duplicateLikeComment(Long commentNo, Integer userId) { + NotificationStatusEntity status = NotificationStatusDao.get().selectOnKey(commentNo, TYPE_COMMENT, userId); + if (status == null) { + return false; + } + return true; + } + + private void saveNotifyStatusLike(Long knowledgeId, Integer userId) { + NotificationStatusEntity status = new NotificationStatusEntity(knowledgeId, TYPE_KNOWLEDGE, userId); + status.setStatus(0); + NotificationStatusDao.get().save(status); + } + private void saveNotifyStatusLikeComment(Long commentNo, Integer userId) { + NotificationStatusEntity status = new NotificationStatusEntity(commentNo, TYPE_COMMENT, userId); + status.setStatus(0); + NotificationStatusDao.get().save(status); + } + + + /** + * いいね!を追加 + * + * @param knowledgeId + * @param loginedUser + * @return + * @throws InvalidParamException + */ + public Long addLike(Long knowledgeId, LoginedUser loginedUser, Locale locale) throws InvalidParamException { + LOG.debug("start addLike"); + if (getCheckOfLike()) { + Resources resources = Resources.getInstance(locale); + if (loginedUser == null || loginedUser.getUserId().equals(Integer.MIN_VALUE)) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_403_FORBIDDEN, resources.getResource("knowledge.likes.required.signin"), "")); + } + LikesEntity likesEntity = LikesDao.get().selectExistsOnUser(knowledgeId, loginedUser.getUserId()); + if (likesEntity != null) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_403_FORBIDDEN, resources.getResource("knowledge.likes.duplicate"), "")); + } + } + LikesDao likesDao = LikesDao.get(); + LikesEntity likesEntity = new LikesEntity(); + likesEntity.setKnowledgeId(knowledgeId); + likesDao.insert(likesEntity); + + KnowledgeLogic.get().updateKnowledgeExInfo(knowledgeId); + + Long count = likesDao.countOnKnowledgeId(knowledgeId); + + // 通知 + int userId = Integer.MIN_VALUE; + if (loginedUser != null) { + userId = loginedUser.getUserId(); + } + if (!duplicateLike(knowledgeId, userId)) { + NotifyLogic.get().notifyOnKnowledgeLiked(knowledgeId, likesEntity); + saveNotifyStatusLike(knowledgeId, userId); + } + + ActivityLogic.get().processActivity(Activity.KNOWLEDGE_LIKE, loginedUser, DateUtils.now(), + KnowledgesDao.get().selectOnKey(knowledgeId)); + + return count; + } + + /** + * コメントにイイネを追加 + * @param commentNo + * @param loginedUser + * @return + * @throws InvalidParamException + */ + public Long addLikeComment(Long commentNo, LoginedUser loginedUser, Locale locale) throws InvalidParamException { + LOG.debug("start addLikeComment"); + if (getCheckOfLike()) { + Resources resources = Resources.getInstance(locale); + if (loginedUser == null || loginedUser.getUserId().equals(Integer.MIN_VALUE)) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_403_FORBIDDEN, resources.getResource("knowledge.likes.required.signin"), "")); + } + LikeCommentsEntity like = LikeCommentsDao.get().selectExistsOnUser(commentNo, loginedUser.getUserId()); + if (like != null) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_403_FORBIDDEN, resources.getResource("knowledge.likes.duplicate"), "")); + } + } + LikeCommentsEntity like = new LikeCommentsEntity(); + like.setCommentNo(commentNo); + like = LikeCommentsDao.get().insert(like); + Long count = LikeCommentsDao.get().selectOnCommentNo(commentNo); + + // 通知 + int userId = Integer.MIN_VALUE; + if (loginedUser != null) { + userId = loginedUser.getUserId(); + } + if (!duplicateLikeComment(commentNo, userId)) { + NotifyLogic.get().notifyOnCommentLiked(like); + saveNotifyStatusLikeComment(commentNo, userId); + } + + ActivityLogic.get().processActivity(Activity.COMMENT_LIKE, loginedUser, DateUtils.now(), + CommentsDao.get().selectOnKey(commentNo)); + + return count; + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/LogManageLogic.java b/src/main/java/org/support/project/knowledge/logic/LogManageLogic.java index 484bf56a1..153141c5d 100644 --- a/src/main/java/org/support/project/knowledge/logic/LogManageLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/LogManageLogic.java @@ -9,6 +9,7 @@ import org.apache.commons.io.FilenameUtils; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.common.util.StringUtils; import org.support.project.di.Container; import org.support.project.knowledge.config.AppConfig; @@ -60,7 +61,7 @@ public void clearLogFiles() { long term = 1000 * 60 * 60 * 24 * days; File[] logs = logFiles(); - Date now = new Date(); + Date now = DateUtils.now(); if (logs != null) { for (File file : logs) { if (now.getTime() - file.lastModified() > term) { diff --git a/src/main/java/org/support/project/knowledge/logic/MailEventLogic.java b/src/main/java/org/support/project/knowledge/logic/MailEventLogic.java index d7c3b8366..70ee9ea1e 100644 --- a/src/main/java/org/support/project/knowledge/logic/MailEventLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MailEventLogic.java @@ -1,43 +1,35 @@ package org.support.project.knowledge.logic; -import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.TimeZone; import org.support.project.aop.Aspect; -import org.support.project.common.config.Resources; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.common.util.StringUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; -import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.dao.EventsDao; import org.support.project.knowledge.dao.KnowledgeItemValuesDao; import org.support.project.knowledge.dao.KnowledgesDao; -import org.support.project.knowledge.dao.ParticipantsDao; -import org.support.project.knowledge.dao.StockKnowledgesDao; import org.support.project.knowledge.entity.EventsEntity; import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; -import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; -import org.support.project.knowledge.entity.ParticipantsEntity; -import org.support.project.knowledge.entity.StockKnowledgesEntity; +import org.support.project.knowledge.logic.notification.EventNotificationByDate; +import org.support.project.knowledge.logic.notification.EventNotificationByMinute; +import org.support.project.knowledge.logic.notification.EventNotificationByWeek; import org.support.project.web.bean.LoginedUser; -import org.support.project.web.dao.MailConfigsDao; -import org.support.project.web.dao.MailsDao; -import org.support.project.web.dao.UsersDao; -import org.support.project.web.entity.MailConfigsEntity; -import org.support.project.web.entity.MailsEntity; -import org.support.project.web.entity.UsersEntity; @DI(instance = Instance.Singleton) public class MailEventLogic extends MailLogic { /** ログ */ private static final Log LOG = LogFactory.getLog(MailEventLogic.class); + public static MailEventLogic get() { + return Container.getComp(MailEventLogic.class); + } public static final int NOTIFY_STATUS_NOT_SEND = 0; /** 今週のイベント通知(日曜に通知) */ @@ -49,25 +41,11 @@ public class MailEventLogic extends MailLogic { /** ステータス:ストック中 */ public static final int STATUS_STOCKED = 100; - - public static MailEventLogic get() { - return Container.getComp(MailEventLogic.class); - } - - /** * 登録されているイベントの開催通知 */ @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) public void notifyEvents() { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - // 登録されているイベントを一週間分取得 // タイムゾーンを考慮して取得するため、少し範囲広めで取得する。 // GMT で先週の土曜〜次週の月曜 @@ -104,179 +82,11 @@ public void notifyEvents() { continue; } List values = KnowledgeItemValuesDao.get().selectOnKnowledgeId(event.getKnowledgeId()); - notifyMin(event, knowledge, values, now, mailConfigsEntity); - notifyDate(event, knowledge, values, now, mailConfigsEntity); - notifyWeek(event, knowledge, values, now, mailConfigsEntity); - } - - } - - private void notifyMin(EventsEntity event, KnowledgesEntity knowledge, List values, - Calendar now, MailConfigsEntity mailConfigsEntity) { - int timing = NOTIFY_STATUS_BEFORE_MIN; - if (event.getNotifyStatus() >= timing) { - // 既に通知済 - return; - } - if (LOG.isDebugEnabled()) { - LOG.debug("開始までの時間: " + (event.getStartDateTime().getTime() - now.getTimeInMillis())); - } - // 30分を切った? - if (event.getStartDateTime().getTime() <= now.getTimeInMillis() || - event.getStartDateTime().getTime() - now.getTimeInMillis() > (1000 * 60 * 30)) { - return; - } - LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 30分前"); - sendNotify(event, knowledge, values, timing); - } - - private void notifyDate(EventsEntity event, KnowledgesEntity knowledge, List values, - Calendar now, MailConfigsEntity mailConfigsEntity) { - int timing = NOTIFY_STATUS_BEFORE_DATE; - if (event.getNotifyStatus() >= timing) { - // 既に通知済 - return; - } - // 今日? - TimeZone timezone = TimeZone.getTimeZone(event.getTimeZone()); - Calendar today = Calendar.getInstance(timezone); - today.setTimeInMillis(now.getTimeInMillis()); - - Calendar eventDay = Calendar.getInstance(timezone); - eventDay.setTimeInMillis(event.getStartDateTime().getTime()); - if (today.get(Calendar.YEAR) != eventDay.get(Calendar.YEAR) || - today.get(Calendar.MONTH) != eventDay.get(Calendar.MONTH) || - today.get(Calendar.DATE) != eventDay.get(Calendar.DATE)) { - // イベント当日以外は通知しない - return; - } - LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 本日開催"); - sendNotify(event, knowledge, values, timing); - } - - private void notifyWeek(EventsEntity event, KnowledgesEntity knowledge, List values, - Calendar now, MailConfigsEntity mailConfigsEntity) { - int timing = NOTIFY_STATUS_BEFORE_WEEK; - if (event.getNotifyStatus() >= timing) { - // 既に通知済 - return; - } - //日曜日?(イベントのタイムゾーンで) - TimeZone timezone = TimeZone.getTimeZone(event.getTimeZone()); - Calendar today = Calendar.getInstance(timezone); - today.setTimeInMillis(now.getTimeInMillis()); - if (today.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { - // 日曜日でない場合は通知しない - return; - } - LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 今週開催"); - sendNotify(event, knowledge, values, timing); - } - - - private void sendNotify(EventsEntity event, KnowledgesEntity knowledge, List values, int timing) { - List userIds = new ArrayList<>(); - // 参加者に通知 - List participants = ParticipantsDao.get().selectOnKnowledgeId(event.getKnowledgeId()); - for (ParticipantsEntity participant : participants) { - if (!userIds.contains(participant.getUserId())) { - UsersEntity user = UsersDao.get().selectOnKey(participant.getUserId()); - if (user != null) { - this.sendNotifyEvent(event, knowledge, values, user, participant.getStatus(), timing); - userIds.add(participant.getUserId()); - } - } - } - // ストックに入れているユーザに通知 - List stocks = StockKnowledgesDao.get().selectOnKnowledgeId(event.getKnowledgeId()); - for (StockKnowledgesEntity stockKnowledgesEntity : stocks) { - if (!userIds.contains(stockKnowledgesEntity.getInsertUser())) { - UsersEntity user = UsersDao.get().selectOnKey(stockKnowledgesEntity.getInsertUser()); - if (user != null) { - this.sendNotifyEvent(event, knowledge, values, user, STATUS_STOCKED, timing); - userIds.add(stockKnowledgesEntity.getInsertUser()); - } - } - } - event.setNotifyStatus(timing); - EventsDao.get().save(event); - } - - - private void sendNotifyEvent(EventsEntity event, KnowledgesEntity knowledge, List values, - UsersEntity user, int status, int timing) { - if (!StringUtils.isEmailAddress(user.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + user.getMailAddress() + "] is wrong."); - return; - } - MailLocaleTemplatesEntity template = load(user.getLocale(), MailLogic.NOTIFY_EVENT); - - String date = ""; - String start = ""; - String end = ""; - String place = ""; - for (KnowledgeItemValuesEntity item : values) { - if (item.getItemNo() == EventsLogic.ITEM_NO_DATE) { - date = item.getItemValue(); - } else if (item.getItemNo() == EventsLogic.ITEM_NO_START) { - start = item.getItemValue(); - } else if (item.getItemNo() == EventsLogic.ITEM_NO_END) { - end = item.getItemValue(); - } else if (item.getItemNo() == EventsLogic.ITEM_NO_PLACE) { - place = item.getItemValue(); - } - } - Resources resources = Resources.getInstance(user.getLocale()); - String statusLabel = ""; - if (status == EventsLogic.STATUS_PARTICIPATION) { - statusLabel = resources.getResource("knowledge.event.label.status.participation"); - } else if (status == EventsLogic.STATUS_WAIT_CANSEL) { - statusLabel = resources.getResource("knowledge.event.label.status.wait.cansel"); - } else if (status == STATUS_STOCKED) { - statusLabel = resources.getResource("knowledge.event.label.status.stocked"); - } - String timingLabel = ""; - if (timing == NOTIFY_STATUS_BEFORE_WEEK) { - timingLabel = resources.getResource("knowledge.event.label.timing.week"); - } else if (timing == NOTIFY_STATUS_BEFORE_DATE) { - timingLabel = resources.getResource("knowledge.event.label.timing.tody"); - } else if (timing == NOTIFY_STATUS_BEFORE_MIN) { - timingLabel = resources.getResource("knowledge.event.label.timing.soon"); + + EventNotificationByMinute.get().notify(event, knowledge, values, now); + EventNotificationByDate.get().notify(event, knowledge, values, now); + EventNotificationByWeek.get().notify(event, knowledge, values, now); } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(user.getMailAddress()); - mailsEntity.setToName(user.getUserName()); - - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - title = title.replace("{Date}", date); - title = title.replace("{Start}", start); - title = title.replace("{End}", end); - title = title.replace("{Place}", place); - mailsEntity.setTitle(title); - - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - contents = contents.replace("{Date}", date); - contents = contents.replace("{Start}", start); - contents = contents.replace("{End}", end); - contents = contents.replace("{Place}", place); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - contents = contents.replace("{Status}", statusLabel); - contents = contents.replace("{Timing}", timingLabel); - contents = contents.replace("{UserName}", user.getUserName()); - mailsEntity.setContent(contents); - MailsDao.get().insert(mailsEntity); } - - - } diff --git a/src/main/java/org/support/project/knowledge/logic/MailLogic.java b/src/main/java/org/support/project/knowledge/logic/MailLogic.java index d9e6b3f48..078b01696 100644 --- a/src/main/java/org/support/project/knowledge/logic/MailLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MailLogic.java @@ -5,14 +5,8 @@ import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Properties; import java.util.UUID; @@ -29,9 +23,7 @@ import org.support.project.aop.Aspect; import org.support.project.common.config.ConfigLoader; -import org.support.project.common.config.INT_FLAG; import org.support.project.common.config.LocaleConfigLoader; -import org.support.project.common.config.Resources; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.common.util.DateUtils; @@ -42,55 +34,26 @@ import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; -import org.support.project.knowledge.bat.WebhookBat; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.MailConfig; -import org.support.project.knowledge.config.NotifyType; import org.support.project.knowledge.config.SystemConfig; -import org.support.project.knowledge.dao.CommentsDao; -import org.support.project.knowledge.dao.ExUsersDao; -import org.support.project.knowledge.dao.KnowledgeItemValuesDao; -import org.support.project.knowledge.dao.KnowledgesDao; -import org.support.project.knowledge.dao.LikesDao; import org.support.project.knowledge.dao.MailLocaleTemplatesDao; import org.support.project.knowledge.dao.MailTemplatesDao; -import org.support.project.knowledge.dao.NotifyConfigsDao; -import org.support.project.knowledge.dao.TargetsDao; -import org.support.project.knowledge.dao.TemplateMastersDao; -import org.support.project.knowledge.dao.WebhookConfigsDao; -import org.support.project.knowledge.dao.WebhooksDao; -import org.support.project.knowledge.entity.CommentsEntity; -import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; -import org.support.project.knowledge.entity.KnowledgesEntity; -import org.support.project.knowledge.entity.LikesEntity; import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; import org.support.project.knowledge.entity.MailTemplatesEntity; -import org.support.project.knowledge.entity.NotifyConfigsEntity; -import org.support.project.knowledge.entity.NotifyQueuesEntity; -import org.support.project.knowledge.entity.TemplateItemsEntity; -import org.support.project.knowledge.entity.TemplateMastersEntity; -import org.support.project.knowledge.entity.WebhookConfigsEntity; -import org.support.project.knowledge.entity.WebhooksEntity; import org.support.project.knowledge.parser.Parser; import org.support.project.knowledge.parser.ParserFactory; -import org.support.project.knowledge.vo.GroupUser; import org.support.project.knowledge.vo.ParseResult; import org.support.project.web.bean.LoginedUser; -import org.support.project.web.config.WebConfig; import org.support.project.web.dao.MailConfigsDao; import org.support.project.web.dao.MailsDao; import org.support.project.web.dao.SystemConfigsDao; -import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.ConfirmMailChangesEntity; -import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.MailConfigsEntity; import org.support.project.web.entity.MailsEntity; import org.support.project.web.entity.PasswordResetsEntity; import org.support.project.web.entity.ProvisionalRegistrationsEntity; import org.support.project.web.entity.SystemConfigsEntity; -import org.support.project.web.entity.UsersEntity; - -import net.arnx.jsonic.JSON; @DI(instance = Instance.Singleton) public class MailLogic { @@ -103,6 +66,7 @@ public class MailLogic { public static final String NOTIFY_INSERT_KNOWLEDGE = "notify_insert_knowledge"; public static final String NOTIFY_UPDATE_KNOWLEDGE = "notify_update_knowledge"; public static final String NOTIFY_INSERT_LIKE_MYITEM = "notify_insert_like_myitem"; + public static final String NOTIFY_INSERT_LIKE_COMMENT_MYITEM = "notify_insert_like_my_comment_item"; public static final String NOTIFY_INSERT_COMMENT = "notify_insert_comment"; public static final String NOTIFY_INSERT_COMMENT_MYITEM = "notify_insert_comment_myitem"; public static final String NOTIFY_ADD_PARTICIPATE = "notify_add_participate"; @@ -112,7 +76,7 @@ public class MailLogic { public static final String NOTIFY_EVENT = "notify_event"; - public static String[] TEMPLATE_IDS = { + public static final String[] TEMPLATE_IDS = { INVITATION, MAIL_CONFIRM, NOTIFY_ACCEPT_USER, NOTIFY_ADD_USER, NOTIFY_INSERT_COMMENT_MYITEM, NOTIFY_INSERT_COMMENT, NOTIFY_INSERT_KNOWLEDGE, NOTIFY_INSERT_LIKE_MYITEM, NOTIFY_UPDATE_KNOWLEDGE, PASSWORD_RESET, TEST_MAIL, @@ -141,18 +105,6 @@ public class MailLogic { // private static final DateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); private static final String MAIL_CONFIG_DIR = "/org/support/project/knowledge/mail/"; - - - /** date format */ - private static DateFormat getDayFormat() { - return new SimpleDateFormat("yyyyMMddHHmmss"); - } - - /** knowledge id what is sended */ - private List sendedCommentKnowledgeIds = new ArrayList<>(); - /** like id what is sended */ - private List sendedLikeKnowledgeIds = new ArrayList<>(); - public static MailLogic get() { return Container.getComp(MailLogic.class); @@ -202,7 +154,8 @@ public MailLocaleTemplatesEntity load(Locale locale, String configName) { * @throws NoSuchAlgorithmException * @throws InvalidKeyException */ - public void startSendMails() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + public void startSendMails() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, + IllegalBlockSizeException, BadPaddingException { MailConfigsDao mailConfigsDao = MailConfigsDao.get(); MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); if (mailConfigsEntity == null) { @@ -215,31 +168,8 @@ public void startSendMails() throws InvalidKeyException, NoSuchAlgorithmExceptio Session session = getSession(mailConfigsEntity); int count = 0; for (MailsEntity mailsEntity : entities) { - if (mailsEntity.getToAddress().matches(MAIL_FORMAT)) { - try { - MailLogic.get().mailSend(session, mailConfigsEntity, mailsEntity); - // ステータス更新 - // mailsEntity.setStatus(MAIL_STATUS_SENDED); - // MailsDao.get().save(mailsEntity); - // 送信処理が終われば、物理削除 - dao.physicalDelete(mailsEntity); - } catch (Exception e) { - LOG.error("mail send error", e); - //メール送信失敗(3回リトライする) - int status = MAIL_STATUS_UNSENT; - if (mailsEntity.getStatus() != null) { - status = mailsEntity.getStatus(); - } - status++; - mailsEntity.setStatus(status); - MailsDao.get().save(mailsEntity); - } - } else { - mailsEntity.setStatus(MAIL_STATUS_FORMAT_ERROR); - dao.save(mailsEntity); - } + startSendMail(session, mailConfigsEntity, mailsEntity); count++; - // 一気に大量に送信しようとするとエラーになることがあるため、少し待機 synchronized (this) { try { @@ -251,6 +181,39 @@ public void startSendMails() throws InvalidKeyException, NoSuchAlgorithmExceptio } LOG.info("MAIL sended. count: " + count); } + /** + * 1件のメールを送信 + * @param mailConfigsEntity + * @param dao + * @param session + * @param mailsEntity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void startSendMail(Session session, MailConfigsEntity mailConfigsEntity, MailsEntity mailsEntity) { + if (mailsEntity.getToAddress().matches(MAIL_FORMAT)) { + try { + MailLogic.get().mailSend(session, mailConfigsEntity, mailsEntity); + // ステータス更新 + mailsEntity.setStatus(MAIL_STATUS_SENDED); + MailsDao.get().save(mailsEntity); + // 送信処理が終われば削除 + // MailsDao.get().delete(mailsEntity); + } catch (Exception e) { + LOG.error("mail send error", e); + //メール送信失敗(3回リトライする) + int status = MAIL_STATUS_UNSENT; + if (mailsEntity.getStatus() != null) { + status = mailsEntity.getStatus(); + } + status++; + mailsEntity.setStatus(status); + MailsDao.get().save(mailsEntity); + } + } else { + mailsEntity.setStatus(MAIL_STATUS_FORMAT_ERROR); + MailsDao.get().save(mailsEntity); + } + } /** * メール送信のセッションを取得 @@ -262,7 +225,8 @@ public void startSendMails() throws InvalidKeyException, NoSuchAlgorithmExceptio * @throws IllegalBlockSizeException * @throws BadPaddingException */ - private Session getSession(MailConfigsEntity config) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + private Session getSession(MailConfigsEntity config) throws InvalidKeyException, NoSuchAlgorithmException, + NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { String host = config.getHost(); String port = String.valueOf(config.getPort()); @@ -327,7 +291,8 @@ public void mailSend(MailConfigsEntity config, MailsEntity entity) throws Invali * @throws NoSuchAlgorithmException * @throws InvalidKeyException */ - private void mailSend(Session session, MailConfigsEntity config, MailsEntity entity) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, + private void mailSend(Session session, MailConfigsEntity config, MailsEntity entity) + throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException, MessagingException { String to = entity.getToAddress(); String toName = entity.getToName(); @@ -356,7 +321,7 @@ private void mailSend(Session session, MailConfigsEntity config, MailsEntity ent // メールの形式を指定 // mimeMessage.setHeader( "Content-Type", "text/html" ); // 送信日付を指定 - mimeMessage.setSentDate(new Date()); + mimeMessage.setSentDate(DateUtils.now()); Transport.send(mimeMessage); LOG.debug("Mail sended."); @@ -364,7 +329,6 @@ private void mailSend(Session session, MailConfigsEntity config, MailsEntity ent /** * メール送信のIDを生成 - * * @param label 11桁まで * @return */ @@ -372,13 +336,12 @@ public String idGen(String label) { StringBuilder builder = new StringBuilder(); builder.append(label); builder.append("-"); - builder.append(DateUtils.getSimpleFormat().format(new Date())); + builder.append(DateUtils.getSimpleFormat().format(DateUtils.now())); builder.append("-"); builder.append(UUID.randomUUID().toString()); return builder.toString(); } - /** * URLを生成 * @@ -484,102 +447,7 @@ public void sendAcceptedAddRequest(ProvisionalRegistrationsEntity entity, String } /** - * ユーザ登録通知 - * - * @param user - */ - public void sendNotifyAddUser(UsersEntity user) { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(org.support.project.knowledge.config.AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - return; - } - - LOG.trace("sendNotifyAddUser"); - SystemConfigsDao configsDao = SystemConfigsDao.get(); - SystemConfigsEntity configsEntity = configsDao.selectOnKey(SystemConfig.USER_ADD_NOTIFY, AppConfig.get().getSystemName()); - if (configsEntity != null && SystemConfig.USER_ADD_NOTIFY_ON.equals(configsEntity.getConfigValue())) { - // 管理者へのメール通知がONなので、メールを送信する - UsersDao usersDao = UsersDao.get(); - List users = usersDao.selectOnRoleKey(WebConfig.ROLE_ADMIN); - for (UsersEntity entity : users) { - if (!StringUtils.isEmailAddress(entity.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + entity.getMailAddress() + "] is wrong."); - continue; - } - Locale locale = entity.getLocale(); - MailLocaleTemplatesEntity mailConfig = load(locale, NOTIFY_ADD_USER); - - String contents = mailConfig.getContent(); - contents = contents.replace("{UserId}", String.valueOf(user.getUserId())); - contents = contents.replace("{UserName}", user.getUserName()); - contents = contents.replace("{UserMail}", user.getMailAddress()); - String title = mailConfig.getTitle(); - - MailsDao mailsDao = MailsDao.get(); - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGen("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(entity.getMailAddress()); - mailsEntity.setToName(entity.getUserName()); - mailsEntity.setTitle(title); - mailsEntity.setContent(contents); - mailsDao.insert(mailsEntity); - } - } - } - - /** - * ユーザの仮登録通知 - * - * @param entity - */ - public void sendNotifyAcceptUser(ProvisionalRegistrationsEntity registrationsEntity) { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(org.support.project.knowledge.config.AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - return; - } - - LOG.trace("sendNotifyAcceptUser"); - SystemConfigsDao configsDao = SystemConfigsDao.get(); - SystemConfigsEntity configsEntity = configsDao.selectOnKey(SystemConfig.USER_ADD_NOTIFY, AppConfig.get().getSystemName()); - if (configsEntity != null && SystemConfig.USER_ADD_NOTIFY_ON.equals(configsEntity.getConfigValue())) { - // 管理者へのメール通知がONなので、メールを送信する - UsersDao usersDao = UsersDao.get(); - List users = usersDao.selectOnRoleKey(WebConfig.ROLE_ADMIN); - for (UsersEntity entity : users) { - if (!StringUtils.isEmailAddress(entity.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + entity.getMailAddress() + "] is wrong."); - continue; - } - Locale locale = entity.getLocale(); - MailLocaleTemplatesEntity mailConfig = load(locale, NOTIFY_ACCEPT_USER); - - String contents = mailConfig.getContent(); - String title = mailConfig.getTitle(); - - MailsDao mailsDao = MailsDao.get(); - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGen("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(entity.getMailAddress()); - mailsEntity.setToName(entity.getUserName()); - mailsEntity.setTitle(title); - mailsEntity.setContent(contents); - mailsDao.insert(mailsEntity); - } - } - } - - /** - * メール変更のリクエストを受付 + * パスワード変更のリクエストを受付 * * @param email * @param locale @@ -686,505 +554,6 @@ public String getMailContent(String content) throws Exception { } return content; } - - - - - /** - * イイネが押された - * @param notifyQueuesEntity - * @throws Exception - */ - @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) - public void notifyLikeInsert(NotifyQueuesEntity notifyQueuesEntity) throws Exception { - LikesDao likesDao = LikesDao.get(); - LikesEntity like = likesDao.selectOnKey(notifyQueuesEntity.getId()); - if (null == like) { - LOG.warn("Like record not found. id: " + notifyQueuesEntity.getId()); - return; - } - - KnowledgesDao knowledgesDao = KnowledgesDao.get(); - KnowledgesEntity knowledge = knowledgesDao.selectOnKey(like.getKnowledgeId()); - if (null == knowledge) { - LOG.warn("Knowledge record not found. id: " + notifyQueuesEntity.getId()); - return; - } - - if (sendedLikeKnowledgeIds.contains(knowledge.getKnowledgeId())) { - if (LOG.isDebugEnabled()) { - LOG.debug("Knowledge [" + knowledge.getKnowledgeId() + "] "); - } - return; - } else { - sendedLikeKnowledgeIds.add(knowledge.getKnowledgeId()); - } - - UsersDao usersDao = UsersDao.get(); - UsersEntity likeUser = usersDao.selectOnKey(like.getInsertUser()); - - // 登録者に通知 - UsersEntity user = usersDao.selectOnKey(knowledge.getInsertUser()); - if (user != null) { - NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); - NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(user.getUserId()); - if (notifyConfigsEntity != null && INT_FLAG.flagCheck(notifyConfigsEntity.getMyItemLike())) { - // 登録者でかつイイネが登録した場合に通知が欲しい - Locale locale = user.getLocale(); - MailLocaleTemplatesEntity template = load(locale, MailLogic.NOTIFY_INSERT_LIKE_MYITEM); - sendLikeMail(like, knowledge, likeUser, user, template); - } - } - } - - /** - * イイネが押されたメールを送る - * @param like - * @param knowledge - * @param likeUser - * @param user - * @param template - * @throws Exception - */ - private void sendLikeMail(LikesEntity like, KnowledgesEntity knowledge, UsersEntity likeUser, UsersEntity user, MailLocaleTemplatesEntity template) - throws Exception { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - if (!StringUtils.isEmailAddress(user.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + user.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(user.getMailAddress()); - mailsEntity.setToName(user.getUserName()); - - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - contents = contents.replace("{Contents}", getContent(knowledge.getContent())); - if (likeUser != null) { - contents = contents.replace("{LikeInsertUser}", likeUser.getUserName()); - } else { - contents = contents.replace("{LikeInsertUser}", ""); - } - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - - mailsEntity.setContent(contents); - if (LOG.isDebugEnabled()) { - LOG.debug("News email has been registered. [type] Like added. [knowledge]" + knowledge.getKnowledgeId().toString() - + " [target] " + user.getMailAddress()); - } - MailsDao.get().insert(mailsEntity); - } - - /** - * ナレッジにコメントが登録された場合の通知 - * @param notifyQueuesEntity - * @throws Exception - */ - @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) - public void notifyCommentInsert(NotifyQueuesEntity notifyQueuesEntity) throws Exception { - CommentsDao commentsDao = CommentsDao.get(); - CommentsEntity comment = commentsDao.selectOnKey(notifyQueuesEntity.getId()); - if (null == comment) { - LOG.warn("Comment record not found. id: " + notifyQueuesEntity.getId()); - return; - } - - KnowledgesDao knowledgesDao = KnowledgesDao.get(); - KnowledgesEntity knowledge = knowledgesDao.selectOnKey(comment.getKnowledgeId()); - if (null == knowledge) { - LOG.warn("Knowledge record not found. id: " + notifyQueuesEntity.getId()); - return; - } - - if (sendedCommentKnowledgeIds.contains(knowledge.getKnowledgeId())) { - if (LOG.isDebugEnabled()) { - LOG.debug("Knowledge [" + knowledge.getKnowledgeId() + "] "); - } - return; - } else { - sendedCommentKnowledgeIds.add(knowledge.getKnowledgeId()); - } - - sendCommentWebhook(comment, knowledge); - - UsersDao usersDao = UsersDao.get(); - UsersEntity commentUser = usersDao.selectOnKey(comment.getInsertUser()); - - // 登録者に通知 - UsersEntity user = NotifyCommentLogic.get().getInsertUserOnComment(NotifyType.Mail, comment, knowledge); - if (user != null) { - Locale locale = user.getLocale(); - MailLocaleTemplatesEntity template = this.load(locale, MailLogic.NOTIFY_INSERT_COMMENT_MYITEM); - sendCommentMail(comment, knowledge, commentUser, user, template); - } - // 宛先のナレッジにコメント追加で通知が欲しいユーザに通知 - List users = NotifyCommentLogic.get().getTargetUsersOnComment(NotifyType.Mail, comment, knowledge); - for (UsersEntity target : users) { - // 宛先にメール送信 - Locale locale = target.getLocale(); - MailLocaleTemplatesEntity template = load(locale, MailLogic.NOTIFY_INSERT_COMMENT); - sendCommentMail(comment, knowledge, commentUser, target, template); - } - } - - /** - * コメント追加のWebhookの登録を行う - * @param comment - * @param knowledge - */ - private void sendCommentWebhook(CommentsEntity comment, KnowledgesEntity knowledge) { - WebhookConfigsDao webhookConfigsDao = WebhookConfigsDao.get(); - List webhookConfigsEntities = webhookConfigsDao.selectOnHook(WebhookConfigsEntity.HOOK_COMMENTS); - - if (0 == webhookConfigsEntities.size()) { - return; - } - - WebhookLogic webhookLogic = WebhookLogic.get(); - Map commentData = webhookLogic.getCommentData(comment, knowledge); - - WebhooksEntity webhooksEntity = new WebhooksEntity(); - String webhookId = idGenu("Notify"); - webhooksEntity.setWebhookId(webhookId); - webhooksEntity.setStatus(WebhookBat.WEBHOOK_STATUS_UNSENT); - webhooksEntity.setHook(WebhookConfigsEntity.HOOK_COMMENTS); - webhooksEntity.setContent(JSON.encode(commentData)); - - WebhooksDao.get().insert(webhooksEntity); - } - - /** - * コメントが追加されたメールを通知する - * @param comment コメントの情報 - * @param knowledge ナレッジの情報 - * @param commentUser コメントを登録したユーザの情報 - * @param user メールの送信先 - * @throws Exception - */ - private void sendCommentMail(CommentsEntity comment, KnowledgesEntity knowledge, UsersEntity commentUser, UsersEntity user, MailLocaleTemplatesEntity template) - throws Exception { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - if (!StringUtils.isEmailAddress(user.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + user.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(user.getMailAddress()); - mailsEntity.setToName(user.getUserName()); - - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - contents = contents.replace("{Contents}", getContent(knowledge.getContent())); - if (commentUser != null) { - contents = contents.replace("{CommentInsertUser}", commentUser.getUserName()); - } else { - contents = contents.replace("{CommentInsertUser}", ""); - } - contents = contents.replace("{CommentContents}", getContent(comment.getComment())); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - - mailsEntity.setContent(contents); - if (LOG.isDebugEnabled()) { - LOG.debug("News email has been registered. [type] comment added. [knowledge]" + knowledge.getKnowledgeId().toString() - + " [target] " + user.getMailAddress()); - } - MailsDao.get().insert(mailsEntity); - } - - - - /** - * ナレッジを登録・更新した際にメール通知を送信する - * @param notifyQueuesEntity - * @throws Exception - */ - @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) - public void notifyKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity) throws Exception { - // ナレッジが登録/更新された - KnowledgesDao knowledgesDao = KnowledgesDao.get(); - KnowledgesEntity knowledge = knowledgesDao.selectOnKeyWithUserName(notifyQueuesEntity.getId()); - if (null == knowledge) { - LOG.warn("Knowledge record not found. id: " + notifyQueuesEntity.getId()); - return; - } - - // Webhook通知 - sendKnowledgeWebhook(knowledge, notifyQueuesEntity.getType()); - // 「非公開」のナレッジは、メール通知対象外 - if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PUBLIC) { - notifyPublicKnowledgeUpdate(notifyQueuesEntity, knowledge); - updateNotifyStatus(knowledge); - } else if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { - notifyProtectKnowledgeUpdate(notifyQueuesEntity, knowledge); - updateNotifyStatus(knowledge); - } - } - - /** - * 通知を送ったもののステータスを更新 - * @param knowledge - */ - private void updateNotifyStatus(KnowledgesEntity knowledge) { - if (knowledge.getNotifyStatus() == null || knowledge.getNotifyStatus().intValue() == 0) { - knowledge.setNotifyStatus(INT_FLAG.ON.getValue()); // 通知済へ - KnowledgesDao.get().physicalUpdate(knowledge); // 更新日時などは更新しない - } - } - - /** - * 「保護」のナレッジを登録・更新した際にメール通知を送信する - * @param notifyQueuesEntity - * @param knowledge - * @throws Exception - */ - private void notifyProtectKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity, KnowledgesEntity knowledge) throws Exception { - List users = new ArrayList<>(); - // 宛先の一覧取得 - TargetsDao targetsDao = TargetsDao.get(); - List targetUsers = targetsDao.selectUsersOnKnowledgeId(knowledge.getKnowledgeId()); - users.addAll(targetUsers); - - //グループの一覧 - List targetGroups = targetsDao.selectGroupsOnKnowledgeId(knowledge.getKnowledgeId()); - for (GroupsEntity groupsEntity : targetGroups) { - List groupUsers = ExUsersDao.get().selectGroupUser(groupsEntity.getGroupId(), 0, Integer.MAX_VALUE); - for (GroupUser groupUser : groupUsers) { - if (!contains(users, groupUser)) { - users.add(groupUser); - } - } - } - - Iterator iterator = users.iterator(); - while (iterator.hasNext()) { - UsersEntity usersEntity = (UsersEntity) iterator.next(); - // 自分宛てのナレッジ登録/更新で通知するかどうかの判定 - NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); - NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(usersEntity.getUserId()); - if (notifyConfigsEntity == null) { - iterator.remove(); - } else if (!INT_FLAG.flagCheck(notifyConfigsEntity.getToItemSave())) { - iterator.remove(); - } - } - notifyKnowledgeUpdateToUsers(notifyQueuesEntity, knowledge, users); - } - /** - * 既に指定のユーザが追加されているのか確認 - * @param users - * @param groupUser - * @return - */ - private boolean contains(List users, UsersEntity groupUser) { - for (UsersEntity usersEntity : users) { - if (usersEntity.equalsOnKey(groupUser)) { - return true; - } - } - return false; - } - - /** - * 「公開」のナレッジを登録・更新した際にメール通知を送信する - * @param notifyQueuesEntity - * @param knowledge - * @throws Exception - */ - private void notifyPublicKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity, KnowledgesEntity knowledge) throws Exception { - //ナレッジ登録ONでかつ、公開区分「公開」を除外しないユーザに通知 - List users = ExUsersDao.get().selectNotifyPublicUsers(); - notifyKnowledgeUpdateToUsers(notifyQueuesEntity, knowledge, users); - } - - /** - * 指定のユーザ一覧に、ナレッジを登録・更新した際にメール通知を送信する - * @param notifyQueuesEntity - * @param knowledge - * @param users - * @throws Exception - */ - private void notifyKnowledgeUpdateToUsers(NotifyQueuesEntity notifyQueuesEntity, KnowledgesEntity knowledge, List users) - throws Exception { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - - StringBuilder content = new StringBuilder(); - // テンプレートの種類をセット - TemplateMastersEntity templateMaster = TemplateMastersDao.get().selectWithItems(knowledge.getTypeId()); - content.append("Type: ").append(templateMaster.getTypeName()).append("\n"); - // テンプレートの拡張項目の情報もメールにセットする - List values = KnowledgeItemValuesDao.get().selectOnKnowledgeId(knowledge.getKnowledgeId()); - List items = templateMaster.getItems(); - for (KnowledgeItemValuesEntity val : values) { - for (TemplateItemsEntity item : items) { - if (val.getItemNo().equals(item.getItemNo())) { - item.setItemValue(val.getItemValue()); - content.append(item.getItemName()).append(": ").append(item.getItemValue()).append("\n"); - break; - } - } - } - if (values.size() > 0) { - content.append("\n"); - } - content.append(knowledge.getContent()); - - for (UsersEntity usersEntity : users) { - if (!StringUtils.isEmailAddress(usersEntity.getMailAddress())) { - // 送信先のメールアドレスが不正なのでこのユーザにはメール送信しない - LOG.warn("mail targget [" + usersEntity.getMailAddress() + "] is wrong."); - continue; - } - if (LOG.isTraceEnabled()) { - LOG.trace("[Notify] " + usersEntity.getMailAddress()); - } - Locale locale = usersEntity.getLocale(); - MailLocaleTemplatesEntity template; - if (knowledge.getNotifyStatus() == null || knowledge.getNotifyStatus().intValue() == 0) { - template = load(locale, MailLogic.NOTIFY_INSERT_KNOWLEDGE); - } else { - template = load(locale, MailLogic.NOTIFY_UPDATE_KNOWLEDGE); - } - insertNotifyKnowledgeUpdateMailQue(knowledge, usersEntity, template, content.toString()); - } - } - - /** - * 記事の追加・更新のWebhookの登録を行う - * @param comment - * @param knowledge - */ - private void sendKnowledgeWebhook(KnowledgesEntity knowledge, int type) { - WebhookConfigsDao webhookConfigsDao = WebhookConfigsDao.get(); - List webhookConfigsEntities = webhookConfigsDao.selectOnHook(WebhookConfigsEntity.HOOK_KNOWLEDGES); - - if (0 == webhookConfigsEntities.size()) { - return; - } - - WebhookLogic webhookLogic = WebhookLogic.get(); - Map knowledgeData = webhookLogic.getKnowledgeData(knowledge, type); - - WebhooksEntity webhooksEntity = new WebhooksEntity(); - String webhookId = idGenu("Notify"); - webhooksEntity.setWebhookId(webhookId); - webhooksEntity.setStatus(WebhookBat.WEBHOOK_STATUS_UNSENT); - webhooksEntity.setHook(WebhookConfigsEntity.HOOK_KNOWLEDGES); - webhooksEntity.setContent(JSON.encode(knowledgeData)); - - WebhooksDao.get().insert(webhooksEntity); - } - - /** - * メール送信のキュー情報を登録する - * @param knowledge - * @param usersEntity - * @param content - * @param config - * @throws Exception - */ - private void insertNotifyKnowledgeUpdateMailQue(KnowledgesEntity knowledge, UsersEntity usersEntity, MailLocaleTemplatesEntity template, String content) throws Exception { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - if (!StringUtils.isEmailAddress(usersEntity.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + usersEntity.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(usersEntity.getMailAddress()); - mailsEntity.setToName(usersEntity.getUserName()); - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - contents = contents.replace("{User}", knowledge.getUpdateUserName()); - - // コンテンツがHTMLであった場合、テキストを取得する - contents = contents.replace("{Contents}", getContent(content)); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - mailsEntity.setContent(contents); - if (LOG.isDebugEnabled()) { - LOG.debug("News email has been registered. [type] knowledge update. [knowledge]" + knowledge.getKnowledgeId().toString() - + " [target] " + usersEntity.getMailAddress()); - } - MailsDao.get().insert(mailsEntity); - } - - /** - * メールにセットする本文の取得 - * @param content - * @return - * @throws Exception - */ - private String getContent(String content) throws Exception { - return MailLogic.get().getMailContent(content); - } - - /** - * メール送信のIDを生成 - * @param string - * @return - */ - protected String idGenu(String label) { - StringBuilder builder = new StringBuilder(); - builder.append(label); - builder.append("-"); - builder.append(getDayFormat().format(new Date())); - builder.append("-"); - builder.append(UUID.randomUUID().toString()); - return builder.toString(); - } - /** @@ -1271,234 +640,4 @@ public void initialize(String templateId) { ja.setContent(jaConfig.getContents()); MailLocaleTemplatesDao.get().save(ja); } - - /** - * 参加登録があったことを、開催者へ通知 - * @param knowledgeId - * @param userId - * @param status - */ - public void notifyAddParticipateForSponsor(Long knowledgeId, Integer userId, Integer status) { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); - if (knowledge == null) { - LOG.info("knowledge [" + knowledgeId + "] is not exists."); - return; - } - // 開催者 - UsersEntity sponsor = UsersDao.get().selectOnKey(knowledge.getInsertUser()); - // 参加者 - UsersEntity participant = UsersDao.get().selectOnKey(userId); - if (sponsor == null || participant == null) { - LOG.warn("sponsor or participant is not exist."); - return; - } - if (!StringUtils.isEmailAddress(sponsor.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + sponsor.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(sponsor.getMailAddress()); - mailsEntity.setToName(sponsor.getUserName()); - - MailLocaleTemplatesEntity template = load(sponsor.getLocale(), NOTIFY_ADD_PARTICIPATE); - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - StringBuilder builder = new StringBuilder(); - Resources resources = Resources.getInstance(sponsor.getLocale()); - builder.append(participant.getUserName()); - if (status == EventsLogic.STATUS_PARTICIPATION) { - builder.append("[").append(resources.getResource("knowledge.view.label.status.participation")).append("]"); - } else { - builder.append("[").append(resources.getResource("knowledge.view.label.status.wait.cansel")).append("]"); - } - contents = contents.replace("{Participant}", builder.toString()); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - - mailsEntity.setContent(contents); - MailsDao.get().insert(mailsEntity); - } - /** - * 参加登録したことを、参加者へ通知 - * @param knowledgeId - * @param userId - * @param status - */ - public void notifyAddParticipateForParticipant(Long knowledgeId, Integer userId, Integer status) { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); - if (knowledge == null) { - LOG.info("knowledge [" + knowledgeId + "] is not exists."); - return; - } - // 参加者 - UsersEntity participant = UsersDao.get().selectOnKey(userId); - if (participant == null) { - LOG.warn("sponsor or participant is not exist."); - return; - } - if (!StringUtils.isEmailAddress(participant.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + participant.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(participant.getMailAddress()); - mailsEntity.setToName(participant.getUserName()); - - MailLocaleTemplatesEntity template = load(participant.getLocale(), NOTIFY_REGISTRATION_EVENT); - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - StringBuilder builder = new StringBuilder(); - Resources resources = Resources.getInstance(participant.getLocale()); - if (status == EventsLogic.STATUS_PARTICIPATION) { - builder.append(resources.getResource("knowledge.view.label.status.participation")); - } else { - builder.append(resources.getResource("knowledge.view.label.status.wait.cansel")); - } - contents = contents.replace("{Status}", builder.toString()); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - - mailsEntity.setContent(contents); - MailsDao.get().insert(mailsEntity); - } - /** - * 参加キャンセルがあったことを、開催者へ通知 - * @param knowledgeId - * @param userId - */ - public void notifyRemoveParticipateForSponsor(Long knowledgeId, Integer userId) { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); - if (knowledge == null) { - LOG.info("knowledge [" + knowledgeId + "] is not exists."); - return; - } - // 開催者 - UsersEntity sponsor = UsersDao.get().selectOnKey(knowledge.getInsertUser()); - // 参加者 - UsersEntity participant = UsersDao.get().selectOnKey(userId); - if (sponsor == null || participant == null) { - LOG.warn("sponsor or participant is not exist."); - return; - } - if (!StringUtils.isEmailAddress(sponsor.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + sponsor.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(sponsor.getMailAddress()); - mailsEntity.setToName(sponsor.getUserName()); - - MailLocaleTemplatesEntity template = load(sponsor.getLocale(), NOTIFY_REMOVE_PARTICIPATE); - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - contents = contents.replace("{Participant}", participant.getUserName()); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - - mailsEntity.setContent(contents); - MailsDao.get().insert(mailsEntity); - } - /** - * キャンセル待ちのユーザに、キャンセルがあったため参加になったことを通知 - * @param knowledgeId - * @param userId - */ - public void notifyChangeParticipateStatusForParticipant(Long knowledgeId, Integer userId) { - MailConfigsDao mailConfigsDao = MailConfigsDao.get(); - MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); - if (mailConfigsEntity == null) { - // メールの設定が登録されていなければ、送信処理は終了 - LOG.info("mail config is not exists."); - return; - } - KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); - if (knowledge == null) { - LOG.info("knowledge [" + knowledgeId + "] is not exists."); - return; - } - // 参加者 - UsersEntity participant = UsersDao.get().selectOnKey(userId); - if (participant == null) { - LOG.warn("sponsor or participant is not exist."); - return; - } - if (!StringUtils.isEmailAddress(participant.getMailAddress())) { - // 送信先のメールアドレスが不正なので、送信処理は終了 - LOG.warn("mail targget [" + participant.getMailAddress() + "] is wrong."); - return; - } - - MailsEntity mailsEntity = new MailsEntity(); - String mailId = idGenu("Notify"); - mailsEntity.setMailId(mailId); - mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); - mailsEntity.setToAddress(participant.getMailAddress()); - mailsEntity.setToName(participant.getUserName()); - - MailLocaleTemplatesEntity template = load(participant.getLocale(), NOTIFY_CHANGE_EVENT_STATUS); - String title = template.getTitle(); - title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); - mailsEntity.setTitle(title); - String contents = template.getContent(); - contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); - contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); - StringBuilder builder = new StringBuilder(); - Resources resources = Resources.getInstance(participant.getLocale()); - builder.append(resources.getResource("knowledge.view.label.status.participation")); - contents = contents.replace("{Status}", builder.toString()); - contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); - - mailsEntity.setContent(contents); - MailsDao.get().insert(mailsEntity); - } - } diff --git a/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java b/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java index d7c596ccf..53987644d 100644 --- a/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java @@ -646,7 +646,7 @@ private String readContent(Multipart multiPart) throws MessagingException, IOExc * @return * @throws Exception */ - private void checkConditionsAndPost(Message msg, List conditions) + public void checkConditionsAndPost(Message msg, List conditions) throws Exception { if (LOG.isDebugEnabled()) { Address[] in = msg.getFrom(); @@ -742,7 +742,7 @@ private boolean checkCondition(Message msg, MailHookConditionsEntity condition) for (Address address : to) { if (address instanceof InternetAddress) { InternetAddress a = (InternetAddress) address; - if (a.getAddress().equals(condition.getCondition())) { + if (a.getAddress().indexOf(condition.getCondition()) != -1) { return true; } } else { diff --git a/src/main/java/org/support/project/knowledge/logic/MarkdownLogic.java b/src/main/java/org/support/project/knowledge/logic/MarkdownLogic.java index 9fa41213c..506c663b2 100644 --- a/src/main/java/org/support/project/knowledge/logic/MarkdownLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MarkdownLogic.java @@ -20,6 +20,7 @@ import org.support.project.common.exception.ParseException; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -107,7 +108,7 @@ private MarkDown sanitize(String markdown, MarkDown result) throws ParseExceptio * @param result */ private void markdownToHtmlOnMarkedJ(String markdown, MarkDown result) { - Date start = new Date(); + Date start = DateUtils.now(); Options options = new Options(); options.setBreaks(true); @@ -121,7 +122,7 @@ private void markdownToHtmlOnMarkedJ(String markdown, MarkDown result) { result.setMarkdown(markdown); if (LOG.isDebugEnabled()) { - Date end = new Date(); + Date end = DateUtils.now(); // 以前、別のMarkdownパーサーのパースが凄く時間がかかったので、パース時間を出力している LOG.debug("Parse time (MarkedJ): " + (end.getTime() - start.getTime()) + " [ms]"); } diff --git a/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java b/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java new file mode 100644 index 000000000..dae78c3cf --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/NotificationLogic.java @@ -0,0 +1,147 @@ +package org.support.project.knowledge.logic; + +import java.util.Iterator; +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.knowledge.logic.notification.AcceptCheckUserNotification; +import org.support.project.knowledge.logic.notification.AddUserNotification; +import org.support.project.knowledge.logic.notification.CommentInsertNotification; +import org.support.project.knowledge.logic.notification.CommentLikedNotification; +import org.support.project.knowledge.logic.notification.EventNotificationByWeek; +import org.support.project.knowledge.logic.notification.KnowledgeUpdateNotification; +import org.support.project.knowledge.logic.notification.LikeInsertNotification; +import org.support.project.knowledge.logic.notification.Notification; +import org.support.project.knowledge.logic.notification.Notification.TARGET; +import org.support.project.knowledge.logic.notification.ParticipateChangeStatusForParticipantNotification; +import org.support.project.knowledge.logic.notification.ParticipateForParticipantNotification; +import org.support.project.knowledge.logic.notification.ParticipateForSponsorNotification; +import org.support.project.knowledge.logic.notification.ParticipateRemoveForSponsorNotification; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.UserNotificationsDao; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UserNotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +public class NotificationLogic extends org.support.project.web.logic.NotificationLogic { + /** + * Get instance + * @return instance + */ + public static NotificationLogic get() { + return Container.getComp(NotificationLogic.class); + } + + /** + * ユーザに通知をセット + * @param notification + * @param usersEntity + */ + public void insertUserNotification(NotificationsEntity notification, UsersEntity usersEntity) { + UserNotificationsEntity userNotification = new UserNotificationsEntity(notification.getNo(), usersEntity.getUserId()); + userNotification.setStatus(NotificationLogic.STATUS_UNREAD); + UserNotificationsDao.get().insert(userNotification); + } + + public Notification getNotification(String category) { + if (MailLogic.NOTIFY_INSERT_KNOWLEDGE.equals(category) || MailLogic.NOTIFY_UPDATE_KNOWLEDGE.equals(category)) { + return KnowledgeUpdateNotification.get(); + } else if (MailLogic.NOTIFY_INSERT_COMMENT_MYITEM.equals(category) || MailLogic.NOTIFY_INSERT_COMMENT.equals(category)) { + return CommentInsertNotification.get(); + } else if (MailLogic.NOTIFY_INSERT_LIKE_MYITEM.equals(category)) { + return LikeInsertNotification.get(); + } else if (MailLogic.NOTIFY_INSERT_LIKE_COMMENT_MYITEM.equals(category)) { + return CommentLikedNotification.get(); + } else if (MailLogic.NOTIFY_EVENT.equals(category)) { + return EventNotificationByWeek.get(); + } else if (MailLogic.NOTIFY_REGISTRATION_EVENT.equals(category)) { + return ParticipateForParticipantNotification.get(); + } else if (MailLogic.NOTIFY_ADD_PARTICIPATE.equals(category)) { + return ParticipateForSponsorNotification.get(); + } else if (MailLogic.NOTIFY_CHANGE_EVENT_STATUS.equals(category)) { + return ParticipateChangeStatusForParticipantNotification.get(); + } else if (MailLogic.NOTIFY_REMOVE_PARTICIPATE.equals(category)) { + return ParticipateRemoveForSponsorNotification.get(); + } else if (MailLogic.NOTIFY_ADD_USER.equals(category)) { + return AddUserNotification.get(); + } else if (MailLogic.NOTIFY_ACCEPT_USER.equals(category)) { + return AcceptCheckUserNotification.get(); + } + return null; + } + + + public List getNotification(LoginedUser loginedUser, int offset, boolean all) { + List notifications = super.getNotification(loginedUser.getUserId(), offset, all); + for (Iterator iterator = notifications.iterator(); iterator.hasNext();) { + NotificationsEntity notificationsEntity = (NotificationsEntity) iterator.next(); + Notification notification = getNotification(notificationsEntity.getTitle()); + if (notification == null) { + iterator.remove(); + } else { + notification.convNotification(notificationsEntity, loginedUser, Notification.TARGET.list); + } + } + return notifications; + } + + + /** + * 通知の読み込み + * @param no + * @param loginedUser + * @return + */ + public NotificationsEntity load(long no, LoginedUser loginedUser) { + UserNotificationsEntity userNotification = UserNotificationsDao.get().selectOnKey(no, loginedUser.getUserId()); + if (userNotification == null) { + return null; + } + NotificationsEntity notificationsEntity = NotificationsDao.get().selectOnKey(no); + if (notificationsEntity == null) { + return null; + } + Notification notification = getNotification(notificationsEntity.getTitle()); + notification.convNotification(notificationsEntity, loginedUser, TARGET.detail); + return notificationsEntity; + } + + public NotificationsEntity previous(long no, LoginedUser loginedUser, boolean all) { + if (loginedUser == null) { + return null; + } + NotificationsEntity notificationsEntity = super.previous(no, loginedUser.getUserId(), all); + if (notificationsEntity == null) { + return null; + } + Notification notification = getNotification(notificationsEntity.getTitle()); + notification.convNotification(notificationsEntity, loginedUser, TARGET.detail); + return notificationsEntity; + } + public NotificationsEntity next(long no, LoginedUser loginedUser, boolean all) { + if (loginedUser == null) { + return null; + } + NotificationsEntity notificationsEntity = super.next(no, loginedUser.getUserId(), all); + if (notificationsEntity == null) { + return null; + } + Notification notification = getNotification(notificationsEntity.getTitle()); + notification.convNotification(notificationsEntity, loginedUser, TARGET.detail); + return notificationsEntity; + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void markAllAsRead(String no, Integer userID) { + String[] nos = no.split(","); + for (String n : nos) { + if (StringUtils.isInteger(n)) { + int num = Integer.parseInt(n); + super.setStatus(userID, num, NotificationLogic.STATUS_READED); + } + } + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java b/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java index ee1990d82..cb7c57267 100644 --- a/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java @@ -1,36 +1,27 @@ package org.support.project.knowledge.logic; import java.util.List; -import java.util.Locale; import org.support.project.common.config.INT_FLAG; -import org.support.project.common.config.Resources; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; -import org.support.project.common.util.NumberUtils; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; -import org.support.project.knowledge.dao.KnowledgeGroupsDao; -import org.support.project.knowledge.dao.KnowledgeUsersDao; -import org.support.project.knowledge.dao.KnowledgesDao; -import org.support.project.knowledge.dao.NotifyConfigsDao; -import org.support.project.knowledge.dao.NotifyQueuesDao; import org.support.project.knowledge.entity.CommentsEntity; -import org.support.project.knowledge.entity.KnowledgeGroupsEntity; -import org.support.project.knowledge.entity.KnowledgeUsersEntity; import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.LikeCommentsEntity; import org.support.project.knowledge.entity.LikesEntity; -import org.support.project.knowledge.entity.NotifyConfigsEntity; -import org.support.project.knowledge.entity.NotifyQueuesEntity; -import org.support.project.knowledge.vo.Notify; +import org.support.project.knowledge.logic.notification.CommentInsertNotification; +import org.support.project.knowledge.logic.notification.CommentLikedNotification; +import org.support.project.knowledge.logic.notification.DesktopNotification; +import org.support.project.knowledge.logic.notification.KnowledgeUpdateNotification; +import org.support.project.knowledge.logic.notification.LikeInsertNotification; +import org.support.project.knowledge.logic.notification.QueueNotification; import org.support.project.knowledge.websocket.NotifyAction; -import org.support.project.web.bean.LoginedUser; -import org.support.project.web.bean.MessageResult; import org.support.project.web.dao.SystemConfigsDao; -import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UsersEntity; /** @@ -49,7 +40,6 @@ public class NotifyLogic { public static NotifyLogic get() { return Container.getComp(NotifyLogic.class); } - /** * 指定のナレッジにアクセスするURLを作成 * @@ -72,37 +62,11 @@ public String makeURL(Long knowledgeId) { builder.append(knowledgeId); return builder.toString(); } - /** - * 通知を処理 - * + * デスクトップ通知を処理(別スレッドで実行) * @param notify */ - private void notify(Notify notify) { - // Mail通知 - NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); - NotifyQueuesEntity notifyQueuesEntity = notify.getQueue(); - // 重複チェックし - if (NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_INSERT)) { - // ナレッジの新規登録は必ず通知のキューに入れる - notifyQueuesDao.insert(notifyQueuesEntity); - } else if (NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_UPDATE)) { - // ナレッジが更新された場合、キューに「登録通知」もしくは「更新通知」が存在しているのであれば登録しない - NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(notifyQueuesEntity.getType(), notifyQueuesEntity.getId()); - if (exist == null) { - exist = notifyQueuesDao.selectOnTypeAndId(Notify.TYPE_KNOWLEDGE_INSERT, notifyQueuesEntity.getId()); - if (exist == null) { - notifyQueuesDao.insert(notifyQueuesEntity); - } - } - } else if (NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_LIKE) - || NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_COMMENT)) { - NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(notifyQueuesEntity.getType(), notifyQueuesEntity.getId()); - if (exist == null) { - notifyQueuesDao.insert(notifyQueuesEntity); - } - } - + private void notifyDeskTop(DesktopNotification notify) { // Desktop通知は、多数のユーザを処理するので、別スレッドで処理する Thread t = new Thread(new Runnable() { @Override @@ -116,16 +80,46 @@ public void run() { t.setDaemon(true); t.start(); } - + /** + * Integer型のフラグをチェック + * + * @param check + * @return + */ + public boolean flagCheck(Integer check) { + if (check == null) { + return false; + } + if (check.intValue() == INT_FLAG.ON.getValue()) { + return true; + } + return false; + } + /** + * 既に指定のユーザが追加されているのか確認 + * @param users + * @param groupUser + * @return + */ + protected boolean contains(List users, UsersEntity groupUser) { + for (UsersEntity usersEntity : users) { + if (usersEntity.equalsOnKey(groupUser)) { + return true; + } + } + return false; + } /** * ナレッジが登録された際の通知 * * @param knowledgesEntity */ public void notifyOnKnowledgeInsert(KnowledgesEntity knowledgesEntity) { - Notify notify = new Notify(); - notify.inserted(knowledgesEntity); - notify(notify); + KnowledgeUpdateNotification notify = KnowledgeUpdateNotification.get(); + notify.setKnowledge(knowledgesEntity); + notify.setType(QueueNotification.TYPE_KNOWLEDGE_INSERT); + notify.insertNotifyQueue(); + notifyDeskTop(notify); } /** @@ -134,10 +128,11 @@ public void notifyOnKnowledgeInsert(KnowledgesEntity knowledgesEntity) { * @param knowledgesEntity */ public void notifyOnKnowledgeUpdate(KnowledgesEntity knowledgesEntity) { - Notify notify = new Notify(); - notify.updated(knowledgesEntity); - - notify(notify); + KnowledgeUpdateNotification notify = KnowledgeUpdateNotification.get(); + notify.setKnowledge(knowledgesEntity); + notify.setType(QueueNotification.TYPE_KNOWLEDGE_UPDATE); + notify.insertNotifyQueue(); + notifyDeskTop(notify); } /** @@ -146,10 +141,11 @@ public void notifyOnKnowledgeUpdate(KnowledgesEntity knowledgesEntity) { * @param knowledgeId */ public void notifyOnKnowledgeLiked(Long knowledgeId, LikesEntity likesEntity) { - Notify notify = new Notify(); - notify.liked(likesEntity); - - notify(notify); + LikeInsertNotification notify = LikeInsertNotification.get(); + notify.setLike(likesEntity); + notify.setType(QueueNotification.TYPE_KNOWLEDGE_LIKE); + notify.insertNotifyQueue(); + notifyDeskTop(notify); } /** @@ -158,175 +154,20 @@ public void notifyOnKnowledgeLiked(Long knowledgeId, LikesEntity likesEntity) { * @param knowledgeId */ public void notifyOnKnowledgeComment(Long knowledgeId, CommentsEntity commentsEntity) { - Notify notify = new Notify(); - notify.commented(commentsEntity); - - notify(notify); - } - - /** - * 指定のナレッジは、自分宛てのナレッジかどうかを判定し、メッセージを取得する - * - * @param loginuser - * @param knowledge - * @return - */ - public MessageResult getInsertKnowledgeMessage(LoginedUser loginuser, Locale locale, KnowledgesEntity knowledge) { - if (isToKnowledgeSave(loginuser, knowledge)) { - MessageResult messageResult = new MessageResult(); - messageResult.setMessage( - Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.to.insert", String.valueOf(knowledge.getKnowledgeId()))); - messageResult.setResult(makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク - return messageResult; - } - return null; - } - - /** - * 指定のナレッジは、自分宛てのナレッジかどうかを判定し、メッセージを取得する - * - * @param loginuser - * @param knowledge - * @return - */ - public MessageResult getUpdateKnowledgeMessage(LoginedUser loginuser, Locale locale, KnowledgesEntity knowledge) { - // TODO ストック機能ができたら、ストックしたナレッジの更新かどうかを判定する - if (isToKnowledgeSave(loginuser, knowledge)) { - MessageResult messageResult = new MessageResult(); - messageResult.setMessage( - Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.to.update", String.valueOf(knowledge.getKnowledgeId()))); - messageResult.setResult(makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク - return messageResult; - } - return null; - } - - /** - * 自分宛てのナレッジが登録/更新されたか判定する - * - * @param loginuser - * @param knowledge - * @return - */ - private boolean isToKnowledgeSave(LoginedUser loginuser, KnowledgesEntity knowledge) { - NotifyConfigsDao dao = NotifyConfigsDao.get(); - NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); - if (!flagCheck(entity.getNotifyDesktop())) { - // デスクトップ通知対象外 - return false; - } -// 自分が登録した場合は、通知する必要無し?いったんは通知する -// if (knowledge.getInsertUser().intValue() == loginuser.getUserId().intValue()) { -// return false; -// } - if (!flagCheck(entity.getToItemSave())) { - // 自分宛てのナレッジが登録/更新されたら通知するがOFF - return false; - } - return isToKnowledge(loginuser, knowledge, entity); - } - - /** - * 指定のナレッジは、自分宛てのナレッジかどうかを判定する 自分宛ては以下の場合を言う ・公開区分が「公開」でかつ、「公開」でも通知する設定になっている場合 ・公開区分が「保護」でかつ、宛先に自分が入っている場合 - * - * @param loginuser - * @param knowledge - * @param entity - * @return - */ - private boolean isToKnowledge(LoginedUser loginuser, KnowledgesEntity knowledge, NotifyConfigsEntity entity) { - if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PUBLIC) { - // 公開のナレッジ - if (!flagCheck(entity.getToItemIgnorePublic())) { - // 公開も除外しない - return true; - } - } else if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { - // 保護のナレッジ - KnowledgeGroupsDao knowledgeGroupsDao = KnowledgeGroupsDao.get(); - List groupsEntities = knowledgeGroupsDao.selectOnKnowledgeId(knowledge.getKnowledgeId()); - List groups = loginuser.getGroups(); - for (KnowledgeGroupsEntity knowledgeGroupsEntity : groupsEntities) { - for (GroupsEntity groupsEntity : groups) { - if (knowledgeGroupsEntity.getGroupId().intValue() == groupsEntity.getGroupId().intValue()) { - return true; - } - } - } - - KnowledgeUsersDao knowledgeUsersDao = KnowledgeUsersDao.get(); - List usersEntities = knowledgeUsersDao.selectOnKnowledgeId(knowledge.getKnowledgeId()); - for (KnowledgeUsersEntity knowledgeUsersEntity : usersEntities) { - if (knowledgeUsersEntity.getUserId().intValue() == loginuser.getUserId().intValue()) { - return true; - } - } - } - return false; - } - - /** - * Integer型のフラグをチェック - * - * @param check - * @return - */ - public boolean flagCheck(Integer check) { - if (check == null) { - return false; - } - if (check.intValue() == INT_FLAG.ON.getValue()) { - return true; - } - return false; - } - - /** - * 指定の「イイネ」の追加で通知するかどうかを判定し、通知する場合はメッセージを取得する - * - * @param loginuser - * @param locale - * @param like - * @return - */ - public MessageResult getSaveLikeMessage(LoginedUser loginuser, Locale locale, LikesEntity like) { - NotifyConfigsDao dao = NotifyConfigsDao.get(); - NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); - if (!flagCheck(entity.getNotifyDesktop())) { - // デスクトップ通知対象外 - return null; - } - KnowledgesDao knowledgesDao = KnowledgesDao.get(); - KnowledgesEntity knowledge = knowledgesDao.selectOnKey(like.getKnowledgeId()); - - if (flagCheck(entity.getMyItemLike()) && knowledge.getInsertUser().intValue() == loginuser.getUserId().intValue()) { - // 自分で投稿したナレッジにイイネが押されたので通知 - MessageResult messageResult = new MessageResult(); - messageResult.setMessage(Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.myitem.like", - String.valueOf(knowledge.getKnowledgeId()))); - messageResult.setResult(makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク - return messageResult; - } - - return null; + CommentInsertNotification notify = CommentInsertNotification.get(); + notify.setComment(commentsEntity); + notify.setType(QueueNotification.TYPE_KNOWLEDGE_COMMENT); + notify.insertNotifyQueue(); + notifyDeskTop(notify); } - - - /** - * 既に指定のユーザが追加されているのか確認 - * @param users - * @param groupUser - * @return - */ - protected boolean contains(List users, UsersEntity groupUser) { - for (UsersEntity usersEntity : users) { - if (usersEntity.equalsOnKey(groupUser)) { - return true; - } - } - return false; + public void notifyOnCommentLiked(LikeCommentsEntity like) { + CommentLikedNotification notify = CommentLikedNotification.get(); + notify.setLike(like); + notify.setType(QueueNotification.TYPE_COMMENT_LIKE); + notify.insertNotifyQueue(); + notifyDeskTop(notify); } - + } diff --git a/src/main/java/org/support/project/knowledge/logic/TargetLogic.java b/src/main/java/org/support/project/knowledge/logic/TargetLogic.java index 157de99eb..ffec8a2f2 100644 --- a/src/main/java/org/support/project/knowledge/logic/TargetLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/TargetLogic.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import org.support.project.common.config.INT_FLAG; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.common.util.StringUtils; @@ -15,8 +16,10 @@ import org.support.project.knowledge.dao.TargetsDao; import org.support.project.web.bean.LabelValue; import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.UserGroupsDao; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.GroupsEntity; +import org.support.project.web.entity.UserGroupsEntity; import org.support.project.web.entity.UsersEntity; @DI(instance = Instance.Singleton) @@ -125,17 +128,36 @@ public Map> selectTargetsOnKnowledgeIds(List knowle } TargetsDao targetsDao = TargetsDao.get(); + List groupIds = new ArrayList(); + Map> groupIdMaps = new HashMap>(); + Map> groupUserIds = new HashMap>(); for (Long knowledgeId : knowledgeIds) { results.put(knowledgeId, new ArrayList()); + groupIdMaps.put(knowledgeId, new ArrayList()); } List groups = targetsDao.selectGroupsOnKnowledgeIds(knowledgeIds); for (GroupsEntity groupsEntity : groups) { + if (groupsEntity.getDeleteFlag() != null && groupsEntity.getDeleteFlag().intValue() == INT_FLAG.ON.getValue()) { + // 削除済のユーザは表示しない + continue; + } LabelValue labelValue = new LabelValue(); labelValue.setLabel(NAME_PREFIX_GROUP + groupsEntity.getGroupName()); labelValue.setValue(ID_PREFIX_GROUP + groupsEntity.getGroupId()); results.get(groupsEntity.getKnowledgeId()).add(labelValue); + groupIdMaps.get(groupsEntity.getKnowledgeId()).add(groupsEntity.getGroupId()); + groupIds.add(groupsEntity.getGroupId()); + groupUserIds.put(groupsEntity.getGroupId(), new ArrayList()); + } + + // フィルターするためにグループに所属するユーザーを取得する + if (!groupIds.isEmpty()) { + List userGroups = UserGroupsDao.get().selectOnGroupIds(groupIds); + for (UserGroupsEntity userGroupsEntity : userGroups) { + groupUserIds.get(userGroupsEntity.getGroupId()).add(userGroupsEntity.getUserId()); + } } List users = targetsDao.selectUsersOnKnowledgeIds(knowledgeIds); @@ -144,6 +166,18 @@ public Map> selectTargetsOnKnowledgeIds(List knowle if (usersEntity.getUserId().intValue() == loginedUser.getUserId().intValue()) { continue; } + + // グループに公開されていてかつそのグループに所属してる場合もスキップ + for (Integer groupId : groupIdMaps.get(usersEntity.getKnowledgeId())) { + if (groupUserIds.get(groupId).contains(usersEntity.getUserId())) { + continue; + } + } + + if (usersEntity.getDeleteFlag() != null && usersEntity.getDeleteFlag().intValue() == INT_FLAG.ON.getValue()) { + // 削除済のユーザは表示しない + continue; + } LabelValue labelValue = new LabelValue(); labelValue.setLabel(NAME_PREFIX_USER + usersEntity.getUserName()); labelValue.setValue(ID_PREFIX_USER + usersEntity.getUserId()); @@ -163,19 +197,94 @@ public List selectEditorsOnKnowledgeId(Long knowledgeId) { List results = new ArrayList<>(); TargetsDao targetsDao = TargetsDao.get(); List groups = targetsDao.selectEditorGroupsOnKnowledgeId(knowledgeId); + List groupIds = new ArrayList(); for (GroupsEntity groupsEntity : groups) { LabelValue labelValue = new LabelValue(); labelValue.setLabel(NAME_PREFIX_GROUP + groupsEntity.getGroupName()); labelValue.setValue(ID_PREFIX_GROUP + groupsEntity.getGroupId()); results.add(labelValue); + groupIds.add(groupsEntity.getGroupId()); + } + List users = targetsDao.selectEditorUsersOnKnowledgeId(knowledgeId); + for (UsersEntity usersEntity : users) { + LabelValue labelValue = new LabelValue(); + labelValue.setLabel(NAME_PREFIX_USER + usersEntity.getUserName()); + labelValue.setValue(ID_PREFIX_USER + usersEntity.getUserId()); + results.add(labelValue); } + return results; + } + + /** + * ナレッジに指定されているアクセス可能なグループを取得(表示用) + * + * @param knowledgeId + * @param loginedUser + * @return + */ + public List selectTargetsViewOnKnowledgeId(Long knowledgeId, LoginedUser loginedUser) { + TargetsDao targetsDao = TargetsDao.get(); + List groups = targetsDao.selectGroupsOnKnowledgeId(knowledgeId); + List users = targetsDao.selectUsersOnKnowledgeId(knowledgeId); + + return filterTargetLabel(groups, users, loginedUser); + } + + /** + * ナレッジに指定されている編集可能なグループを取得(表示用) + * + * @param knowledgeId + * @param loginedUser + * @return + */ + public List selectEditorsViewOnKnowledgeId(Long knowledgeId, LoginedUser loginedUser) { + TargetsDao targetsDao = TargetsDao.get(); + List groups = targetsDao.selectEditorGroupsOnKnowledgeId(knowledgeId); List users = targetsDao.selectEditorUsersOnKnowledgeId(knowledgeId); + + return filterTargetLabel(groups, users, loginedUser); + } + + /** + * ターゲットのラベルをフィルターする + * + * @param groups + * @param users + * @param loginedUser + * @return + */ + public List filterTargetLabel(List groups, List users, LoginedUser loginedUser) { + List results = new ArrayList<>(); + List groupIds = new ArrayList(); + + for (GroupsEntity groupsEntity : groups) { + LabelValue labelValue = new LabelValue(); + labelValue.setLabel(NAME_PREFIX_GROUP + groupsEntity.getGroupName()); + labelValue.setValue(ID_PREFIX_GROUP + groupsEntity.getGroupId()); + results.add(labelValue); + groupIds.add(groupsEntity.getGroupId()); + } + + // フィルターするためにグループに所属するユーザーを取得する + List groupUserIds = new ArrayList(); + if (!groupIds.isEmpty()) { + List userGroups = UserGroupsDao.get().selectOnGroupIds(groupIds); + for (UserGroupsEntity userGroupsEntity : userGroups) { + groupUserIds.add(userGroupsEntity.getUserId()); + } + } + for (UsersEntity usersEntity : users) { + // グループに公開されていてかつそのグループに所属してる場合はスキップ + if (groupUserIds.contains(usersEntity.getUserId())) { + continue; + } LabelValue labelValue = new LabelValue(); labelValue.setLabel(NAME_PREFIX_USER + usersEntity.getUserName()); labelValue.setValue(ID_PREFIX_USER + usersEntity.getUserId()); results.add(labelValue); } + return results; } diff --git a/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java b/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java index e8fb80b72..adfd95046 100644 --- a/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java @@ -155,6 +155,7 @@ public TemplateMastersEntity updateTemplate(TemplateMastersEntity template, Logi db.setTypeName(template.getTypeName()); db.setTypeIcon(template.getTypeIcon()); db.setDescription(template.getDescription()); + db.setInitialValue(template.getInitialValue()); templateDao.update(db); Integer typeId = template.getTypeId(); diff --git a/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java b/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java index e6a932983..ab8ed72d6 100644 --- a/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java @@ -84,7 +84,7 @@ public UploadFile saveFile(FileItem fileItem, LoginedUser loginedUser, String co public UploadFile saveFile(byte[] img, LoginedUser loginedUser, String context) { LOG.trace("saveFile()"); KnowledgeFilesEntity entity = new KnowledgeFilesEntity(); - entity.setFileName("image-" + DateUtils.formatTransferDateTime(new Date()) + ".png"); + entity.setFileName("image-" + DateUtils.formatTransferDateTime(DateUtils.now()) + ".png"); entity.setFileSize(new Double(img.length)); entity.setFileBinary(new ByteArrayInputStream(img)); entity.setParseStatus(0); diff --git a/src/main/java/org/support/project/knowledge/logic/WebhookLogic.java b/src/main/java/org/support/project/knowledge/logic/WebhookLogic.java index 69a0f29bb..f6c9d27a8 100644 --- a/src/main/java/org/support/project/knowledge/logic/WebhookLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/WebhookLogic.java @@ -26,7 +26,7 @@ import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.TagsEntity; import org.support.project.knowledge.entity.WebhookConfigsEntity; -import org.support.project.knowledge.vo.Notify; +import org.support.project.knowledge.logic.notification.QueueNotification; import org.support.project.web.bean.LabelValue; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.ProxyConfigsEntity; @@ -85,7 +85,7 @@ public Map getKnowledgeData(KnowledgesEntity knowledge, Integer jsonObject.put("became_public", became_public); if (type != null) { - if (Notify.TYPE_KNOWLEDGE_INSERT == type) { + if (QueueNotification.TYPE_KNOWLEDGE_INSERT == type) { jsonObject.put("status", "created"); } else { jsonObject.put("status", "updated"); diff --git a/src/main/java/org/support/project/knowledge/logic/activity/AbstractActivityProcessor.java b/src/main/java/org/support/project/knowledge/logic/activity/AbstractActivityProcessor.java new file mode 100644 index 000000000..28bd6f6dc --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/AbstractActivityProcessor.java @@ -0,0 +1,188 @@ +package org.support.project.knowledge.logic.activity; + + +import java.sql.Timestamp; +import java.util.Date; + +import org.support.project.aop.Aspect; +import org.support.project.common.config.INT_FLAG; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.UserConfig; +import org.support.project.knowledge.dao.ActivitiesDao; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.PointKnowledgeHistoriesDao; +import org.support.project.knowledge.dao.PointUserHistoriesDao; +import org.support.project.knowledge.entity.ActivitiesEntity; +import org.support.project.knowledge.entity.PointKnowledgeHistoriesEntity; +import org.support.project.knowledge.entity.PointUserHistoriesEntity; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.UserConfigsDao; +import org.support.project.web.entity.UserConfigsEntity; + +/** + * Activityに対応して、ポイントを付与する + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public abstract class AbstractActivityProcessor implements ActivityProcessor { + private static final Log LOG = LogFactory.getLog(AbstractActivityProcessor.class); + private static Object lockUser = new Object(); + private static Object lockKnowledge = new Object(); + + protected LoginedUser eventUser; + protected Date eventDateTime; + /** + * @param eventUser the eventUser to set + */ + public void setEventUser(LoginedUser eventUser) { + this.eventUser = eventUser; + } + /** + * @param eventDateTime the eventDateTime to set + */ + public void setEventDateTime(Date eventDateTime) { + this.eventDateTime = eventDateTime; + } + + /** + * ポイントと種類を保持する内部クラス + * @author koda + */ + protected class TypeAndPoint { + int type; + int point; + TypeAndPoint(int type, int point) { + this.type = type; + this.point = point; + } + } + + /** + * 対象のactivityが既に登録されているかチェック + * @param userId アクティビティを実行したユーザ + * @param kind アクティビティの種類 + * @param target そのアクティビティでポイントを付与する対象 + * @return + */ + protected boolean isExistsActivity(int userId, Activity kind, String target) { + ActivitiesEntity entity = ActivitiesDao.get().select(userId, kind.getValue(), target); + if (entity == null) { + return false; + } + return true; + } + + /** + * activity登録 + * @param kind アクティビティの種類 + * @param target そのアクティビティでポイントを付与する対象 + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + protected ActivitiesEntity addActivity(Activity kind, String target) { + ActivitiesEntity entity = new ActivitiesEntity(); + entity.setUserId(eventUser.getUserId()); + entity.setKind(kind.getValue()); + entity.setTarget(target); + entity.setInsertUser(eventUser.getUserId()); + entity.setInsertDatetime(new Timestamp(eventDateTime.getTime())); + entity.setDeleteFlag(INT_FLAG.OFF.getValue()); + entity = ActivitiesDao.get().physicalInsert(entity); + return entity; + } + + /** + * ポイントをユーザに加算 + * @param eventUser + * @param eventTime + * @param targetUser + * @param activityNo + * @param type + * @param point + * @return + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + protected int addPointForUser(int targetUser, long activityNo, int type, int point) { + synchronized(lockUser) { + UserConfigsEntity config = UserConfigsDao.get().selectOnKey(UserConfig.POINT, AppConfig.get().getSystemName(), targetUser); + if (config == null) { + config = new UserConfigsEntity(UserConfig.POINT, AppConfig.get().getSystemName(), targetUser); + config.setConfigValue("0"); + } + if (!StringUtils.isInteger(config.getConfigValue())) { + config.setConfigValue("0"); + } + + int before = Integer.parseInt(config.getConfigValue()); + int now = before + point; + if (LOG.isDebugEnabled()) { + LOG.debug("Add point [user]" + targetUser + " [point]" + point + " [before]" + before + " [now]" + now); + } + config.setConfigValue(String.valueOf(now)); + UserConfigsDao.get().save(config); + + long num = PointUserHistoriesDao.get().selectNumOnUser(targetUser); + num++; + PointUserHistoriesEntity history = new PointUserHistoriesEntity(); + history.setUserId(targetUser); + history.setHistoryNo(num); + history.setActivityNo(activityNo); + history.setType(type); + history.setPoint(point); + history.setBeforeTotal(before); + history.setTotal(now); + history.setInsertUser(eventUser.getUserId()); + history.setInsertDatetime(new Timestamp(eventDateTime.getTime())); + history.setDeleteFlag(INT_FLAG.OFF.getValue()); + PointUserHistoriesDao.get().physicalInsert(history); + + return now; + } + } + /** + * 記事にポイントを加算 + * @param eventUser + * @param eventTime + * @param knowledgeId + * @param activityNo + * @param type + * @param point + * @return + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + protected int addPointForKnowledge(long knowledgeId, long activityNo, int type, int point) { + synchronized (lockKnowledge) { + // Daoのupdateメソッドなどを使うと、「更新者」が更新されるので、ポイントのみを更新するメソッドを呼ぶ + // なお、記事の存在チェックは行わない + int before = KnowledgesDao.get().selectPoint(knowledgeId); + int now = before + point; + if (LOG.isDebugEnabled()) { + LOG.debug("Add point [knowledge]" + knowledgeId + " [point]" + point + " [before]" + before + " [now]" + now); + } + KnowledgesDao.get().updatePoint(knowledgeId, now); + + long num = PointKnowledgeHistoriesDao.get().selectNumOnKnowledge(knowledgeId); + num++; + PointKnowledgeHistoriesEntity history = new PointKnowledgeHistoriesEntity(); + history.setKnowledgeId(knowledgeId); + history.setHistoryNo(num); + history.setActivityNo(activityNo); + history.setType(type); + history.setPoint(point); + history.setBeforeTotal(before); + history.setTotal(now); + history.setInsertUser(eventUser.getUserId()); + history.setInsertDatetime(new Timestamp(eventDateTime.getTime())); + history.setDeleteFlag(INT_FLAG.OFF.getValue()); + PointKnowledgeHistoriesDao.get().physicalInsert(history); + + return now; + } + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/AbstractAddPointForCommentProcessor.java b/src/main/java/org/support/project/knowledge/logic/activity/AbstractAddPointForCommentProcessor.java new file mode 100644 index 000000000..55bf571d1 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/AbstractAddPointForCommentProcessor.java @@ -0,0 +1,110 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.ActivitiesEntity; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; + +@DI(instance = Instance.Prototype) +public abstract class AbstractAddPointForCommentProcessor extends AbstractActivityProcessor { + private static final Log LOG = LogFactory.getLog(AbstractAddPointForCommentProcessor.class); + private CommentsEntity comment; + private KnowledgesEntity parentKnowledge; + /** + * @return the comment + */ + public CommentsEntity getComment() { + return comment; + } + /** + * @param comment the comment to set + */ + public void setComment(CommentsEntity comment) { + this.comment = comment; + this.parentKnowledge = KnowledgesDao.get().selectOnKey(getComment().getKnowledgeId()); + } + public KnowledgesEntity getParentKnowledge() { + return parentKnowledge; + } + + protected abstract Activity getActivity(); + protected abstract TypeAndPoint getTypeAndPointForActivityExecuter(); + protected abstract TypeAndPoint getTypeAndPointForCommentOwner(); + protected abstract TypeAndPoint getTypeAndPointForKnowledge(); + + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void execute() throws Exception { + if (getComment() == null || eventUser == null) { + // ありえないけど念のため確認 + return; + } + if (isExistsActivity(eventUser.getUserId(), getActivity(), String.valueOf(getComment().getCommentNo()))) { + LOG.debug("This activity is already exists. [Activity]" + getActivity().toString() + " [user]" + eventUser.getUserId() + + " [comment]" + getComment().getCommentNo()); + return; + } + if (parentKnowledge == null) { + LOG.debug("Knowledge is not found. [comment] " + getComment().getCommentNo() + " [knowledge]" + getComment().getKnowledgeId()); + return; + } + + TypeAndPoint exec = getTypeAndPointForActivityExecuter(); + TypeAndPoint owner = getTypeAndPointForCommentOwner(); + TypeAndPoint knowledge = getTypeAndPointForKnowledge(); + if (exec == null && owner == null && knowledge == null) { + // ポイントをつける対象が無いので、処理終了 + LOG.debug("This activity is not add point. [Activity]" + getActivity().toString() + " [user]" + eventUser.getUserId() + + " [comment]" + getComment().getCommentNo()); + return; + } + + + LOG.debug("activity process started. [Activity]" + getActivity().toString() + " [user]" + eventUser.getUserId() + + " [comment]" + getComment().getCommentNo()); + + StringBuilder logmsg = new StringBuilder(); + logmsg.append("Activity : " + getActivity().toString()); + + // ポイント発行アクティビティを生成 + ActivitiesEntity activity = addActivity( + getActivity(), + String.valueOf(getComment().getCommentNo())); + + // 実行したユーザのポイントアップ + if (exec != null) { + int point = addPointForUser( + eventUser.getUserId(), // ターゲットは、実行したユーザ + activity.getActivityNo(), + exec.type, + exec.point); + logmsg.append("\n\tAdd event user: [id]" + eventUser.getUserId() + " [type]" + exec.type + " [add]" + exec.point + " [result]" + point); + } + // コメントの登録者のポイントをアップ + if (owner != null) { + int point = addPointForUser( + getComment().getInsertUser(), // ターゲットは登録者 + activity.getActivityNo(), + owner.type, + owner.point); + logmsg.append("\n\tAdd owner user: [id]" + getComment().getInsertUser() + " [type]" + owner.type + " [add]" + owner.point + " [result]" + point); + } + // 記事のポイントアップ(コメントにはポイントをもっていないので、親のナレッジのポイントをアップ) + if (knowledge != null) { + int point = addPointForKnowledge( + parentKnowledge.getKnowledgeId(), + activity.getActivityNo(), + knowledge.type, + knowledge.point); + logmsg.append("\n\tAdd knowledge: [id]" + parentKnowledge.getKnowledgeId() + " [type]" + knowledge.type + " [add]" + knowledge.point + " [result]" + point); + } + LOG.debug(logmsg.toString()); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/AbstractAddPointForKnowledgeProcessor.java b/src/main/java/org/support/project/knowledge/logic/activity/AbstractAddPointForKnowledgeProcessor.java new file mode 100644 index 000000000..81281df4e --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/AbstractAddPointForKnowledgeProcessor.java @@ -0,0 +1,110 @@ +package org.support.project.knowledge.logic.activity; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.entity.ActivitiesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; + +@DI(instance = Instance.Prototype) +public abstract class AbstractAddPointForKnowledgeProcessor extends AbstractActivityProcessor { + private static final Log LOG = LogFactory.getLog(AbstractAddPointForKnowledgeProcessor.class); + private KnowledgesEntity knowledge; + /** + * @return the knowledge + */ + public KnowledgesEntity getKnowledge() { + return knowledge; + } + /** + * @param knowledge the knowledge to set + */ + public void setKnowledge(KnowledgesEntity knowledge) { + this.knowledge = knowledge; + } + + protected abstract Activity getActivity(); + protected abstract TypeAndPoint getTypeAndPointForActivityExecuter(); + protected abstract TypeAndPoint getTypeAndPointForKnowledgeOwner(); + protected abstract TypeAndPoint getTypeAndPointForKnowledge(); + + private List multiAbleActivities = new ArrayList<>(); + public AbstractAddPointForKnowledgeProcessor() { + super(); + multiAbleActivities.add(Activity.KNOWLEDGE_POST_PRIVATE); + multiAbleActivities.add(Activity.KNOWLEDGE_POST_PROTECTED); + multiAbleActivities.add(Activity.KNOWLEDGE_POST_PUBLIC); + } + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void execute() throws Exception { + if (getKnowledge() == null || eventUser == null) { + // ありえないけど念のため確認 + return; + } + Activity activity = getActivity(); + if (!multiAbleActivities.contains(activity)) { + if (isExistsActivity(eventUser.getUserId(), activity, String.valueOf(getKnowledge().getKnowledgeId()))) { + LOG.debug("This activity is already exists. [Activity]" + activity.toString() + " [user]" + eventUser.getUserId() + + " [knowledge]" + getKnowledge().getKnowledgeId()); + // 既に指定のKnowledge登録済 + return; + } + } + + TypeAndPoint exec = getTypeAndPointForActivityExecuter(); + TypeAndPoint owner = getTypeAndPointForKnowledgeOwner(); + TypeAndPoint knowledge = getTypeAndPointForKnowledge(); + if (exec == null && owner == null && knowledge == null) { + // ポイントをつける対象が無いので、処理終了 + LOG.debug("This activity is not add point. [Activity]" + activity.toString() + " [user]" + eventUser.getUserId() + + " [knowledge]" + getKnowledge().getKnowledgeId()); + return; + } + LOG.debug("activity process started. [Activity]" + activity.toString() + " [user]" + eventUser.getUserId() + + " [knowledge]" + getKnowledge().getKnowledgeId()); + + StringBuilder logmsg = new StringBuilder(); + logmsg.append("Activity : " + activity.toString()); + // ポイント発行アクティビティを生成 + ActivitiesEntity activityEntry = addActivity( + activity, + String.valueOf(getKnowledge().getKnowledgeId())); + + // 実行したユーザのポイントアップ + if (exec != null) { + int point = addPointForUser( + eventUser.getUserId(), // ターゲットは、実行したユーザ + activityEntry.getActivityNo(), + exec.type, + exec.point); + logmsg.append("\n\tAdd event user: [id]" + eventUser.getUserId() + " [type]" + exec.type + " [add]" + exec.point + " [result]" + point); + } + // 記事の登録者のポイントをアップ + if (owner != null) { + int point = addPointForUser( + getKnowledge().getInsertUser(), // ターゲットは登録者 + activityEntry.getActivityNo(), + owner.type, + owner.point); + logmsg.append("\n\tAdd owner user: [id]" + getKnowledge().getInsertUser() + " [type]" + owner.type + " [add]" + owner.point + " [result]" + point); + } + // 記事のポイントアップ + if (knowledge != null) { + int point = addPointForKnowledge( + getKnowledge().getKnowledgeId(), + activityEntry.getActivityNo(), + knowledge.type, + knowledge.point); + logmsg.append("\n\tAdd knowledge: [id]" + getKnowledge().getKnowledgeId() + " [type]" + knowledge.type + " [add]" + knowledge.point + " [result]" + point); + } + LOG.debug(logmsg.toString()); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/Activity.java b/src/main/java/org/support/project/knowledge/logic/activity/Activity.java new file mode 100644 index 000000000..4ffb3fe28 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/Activity.java @@ -0,0 +1,137 @@ +package org.support.project.knowledge.logic.activity; + +/** + * ポイントが増減するアクティビティの種類 + * + * 種類 | ターゲット文字列 | イベントの内容 + * 1 | knowledge_id | 記事を登録(使わない) + * 2 | knowledge_id | 記事参照 + * 3 | knowledge_id | 記事へイイネを登録 + * 4 | knowledge_id | 記事をストック + * 5 | knowledge_id | アンケート回答 + * 6 | knowledge_id | イベント参加 + * 10 | knowledge_id | 記事を「公開」で投稿(登録/更新時)→増える + * 11 | knowledge_id | 記事を「保護」で投稿(登録/更新時)→前が非公開であれば増える、前が公開であれば減る + * 12 | knowledge_id | 記事を「非公開」で投稿(登録/更新時)→前が「公開」「保護」の場合減る(前が「公開」「保護」で無い場合登録しない/非公開の記事ではポイント増えない) + * 101 | comment_no | コメント登録 + * 103 | comment_no | コメントにイイネ登録 + * -6 | knowledge_id | イベント参加の取り消し + * + * --------------------------------------------------------------------------- + * + * ポイント操作 + * + * 種類 | 獲得のタイプ | ポイント付与先 | ポイント | 獲得タイプの意味 + * 1 | 11 | 記事登録者 | 50 | 記事を投稿したら投稿者にポイント追加(使わない) + * 1 | 13 | 記事 | 50 | 登録された記事のポイント初期値(使わない) + * 2 | 21 | 参照者 | 1 | 記事を参照するアクションを行うと、参照者にポイント追加(一つの記事に付き1回のみ) + * 2 | 22 | 記事登録者 | 1 | 自分が登録された記事が参照されたら、登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 2 | 23 | 記事 | 1 | 記事が参照されると、その記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * 3 | 31 | 参照者 | 2 | 記事にイイネのアクションを行うと、参照者にポイント追加(一つの記事に付き1回のみ) + * 3 | 32 | 記事登録者 | 10 | 自分が登録された記事にイイネがついたら、登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 3 | 33 | 記事 | 10 | 記事が参照されると、その記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * 4 | 41 | 参照者 | 0 | ストックした場合、ストックした人にポイントは付与しない + * 4 | 42 | 記事登録者 | 2 | 記事の登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 4 | 43 | 記事 | 2 | 記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * 5 | 51 | 参照者 | 3 | アンケート回答者にポイント付与 + * 5 | 52 | 記事登録者 | 3 | 記事の登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 5 | 53 | 記事 | 3 | 記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * 6 | 61 | 参照者 | 5 | イベント参加者にポイント付与 + * 6 | 62 | 記事登録者 | 5 | 記事の登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 6 | 63 | 記事 | 5 | 記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * 10 | 101 | 記事登録者 | 50 | 公開になった時点でトータル50になるように + * 10 | 103 | 記事 | 50 | + * 11 | 111 | 記事登録者 | 30 | + * 11 | 113 | 記事 | 30 | + * 12 | 121 | 記事登録者 | 0 | このアクティビティの前に、投稿のアクティビティがあった場合、それを打ち消す(マイナスのポイント) + * 12 | 123 | 記事 | 0 | + * 101 | 1011 | 登録者 | 20 | コメントを投稿すると、投稿者にポイント追加 + * 101 | 1013 | 記事 | 20 | 記事にコメントが付くと、その記事に対しポイント追加 + * 103 | 1031 | 参照者 | 2 | イイネを押すと、押した人にポイント追加 + * 103 | 1032 | 登録者 | 10 | コメントにイイネが付くと、そのコメントを登録したユーザにポイントが付く + * 103 | 1033 | 記事 | 10 | コメントにイイネがつくと、そのコメントの記事に対しポイント追加 + * -6 | -61 | 参照者 | 5 | イベント参加者にポイント付与(取り消しなのでマイナス) + * -6 | -62 | 記事登録者 | 5 | 記事の登録者にポイント追加(取り消しなのでマイナス) + * -6 | -63 | 記事 | 5 | 記事のポイントが追加(取り消しなのでマイナス) + * + * ユーザのポイントは、USER_CONFIGSテーブルへ格納する + * ポイントはランダムで少し増減した方が面白い?? + * ポイントは、だいたいの定義で、各実装の処理内で拡張する(例えば、イイネは、件数が増える毎に、ナレッジに付くポイントは増加するとか) + * + * @author koda + */ +public enum Activity { + NONE, + KNOWLEDGE_INSERT, // 記事登録 + KNOWLEDGE_SHOW, // 記事参照 + KNOWLEDGE_LIKE, // イイネを押した + KNOWLEDGE_STOCK, // ストックした + KNOWLEDGE_ANSWER, // アンケートに回答した + KNOWLEDGE_EVENT_ADD, // イベントに参加した + KNOWLEDGE_EVENT_DELETE, // イベント参加キャンセル + KNOWLEDGE_POST_PUBLIC, // 公開で投稿 + KNOWLEDGE_POST_PROTECTED, // 保護で投稿 + KNOWLEDGE_POST_PRIVATE, // 非公開で投稿 + COMMENT_INSERT, // コメント追加 + COMMENT_LIKE; // コメントにイイネを押した + + public int getValue() { + if (this == KNOWLEDGE_INSERT) { + return 1; + } else if (this ==KNOWLEDGE_SHOW) { + return 2; + } else if (this ==KNOWLEDGE_LIKE) { + return 3; + } else if (this ==KNOWLEDGE_STOCK) { + return 4; + } else if (this ==KNOWLEDGE_ANSWER) { + return 5; + } else if (this ==KNOWLEDGE_EVENT_ADD) { + return 6; + } else if (this ==KNOWLEDGE_EVENT_DELETE) { + return -6; + } else if (this ==KNOWLEDGE_POST_PUBLIC) { + return 10; + } else if (this ==KNOWLEDGE_POST_PROTECTED) { + return 11; + } else if (this ==KNOWLEDGE_POST_PRIVATE) { + return 12; + } else if (this ==COMMENT_INSERT) { + return 101; + } else if (this ==COMMENT_LIKE) { + return 102; + } + return Integer.MIN_VALUE; + } + + public static Activity getType(int type) { + if (type == 1) { + return KNOWLEDGE_INSERT; + } else if (type == 2) { + return KNOWLEDGE_SHOW; + } else if (type == 3) { + return KNOWLEDGE_LIKE; + } else if (type == 4) { + return KNOWLEDGE_STOCK; + } else if (type == 5) { + return KNOWLEDGE_ANSWER; + } else if (type == 6) { + return KNOWLEDGE_EVENT_ADD; + } else if (type == -6) { + return KNOWLEDGE_EVENT_DELETE; + } else if (type == 10) { + return KNOWLEDGE_POST_PUBLIC; + } else if (type == 11) { + return KNOWLEDGE_POST_PROTECTED; + } else if (type == 12) { + return KNOWLEDGE_POST_PRIVATE; + } else if (type == 101) { + return COMMENT_INSERT; + } else if (type == 102) { + return COMMENT_LIKE; + } + return NONE; + } + +} + diff --git a/src/main/java/org/support/project/knowledge/logic/activity/ActivityLogic.java b/src/main/java/org/support/project/knowledge/logic/activity/ActivityLogic.java new file mode 100644 index 000000000..9caaac1b5 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/ActivityLogic.java @@ -0,0 +1,277 @@ +package org.support.project.knowledge.logic.activity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.support.project.aop.Aspect; +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.HtmlUtils; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.dao.ActivitiesDao; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.PointUserHistoriesDao; +import org.support.project.knowledge.entity.ActivitiesEntity; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.PointUserHistoriesEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.vo.ActivityHistory; +import org.support.project.knowledge.vo.ContributionPointHistory; +import org.support.project.knowledge.vo.UserConfigs; +import org.support.project.ormapping.config.Order; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.logic.DateConvertLogic; + +@DI(instance = Instance.Singleton) +public class ActivityLogic { + /** ログ */ + private static final Log LOG = LogFactory.getLog(ActivityLogic.class); + + public static ActivityLogic get() { + return Container.getComp(ActivityLogic.class); + } + + private List getActivityProcessors(Activity activity) { + List array = new ArrayList<>(); + if (activity == Activity.KNOWLEDGE_POST_PUBLIC + || activity == Activity.KNOWLEDGE_POST_PROTECTED + || activity == Activity.KNOWLEDGE_POST_PRIVATE) { + array.add(KnowledgeSaveActivity.get()); + } else if (activity == Activity.KNOWLEDGE_SHOW) { + array.add(KnowledgeShowActivity.get()); + } else if (activity == Activity.KNOWLEDGE_LIKE) { + array.add(KnowledgeLikeActivity.get()); + } else if (activity == Activity.KNOWLEDGE_STOCK) { + array.add(KnowledgeStockActivity.get()); + } else if (activity == Activity.KNOWLEDGE_ANSWER) { + array.add(KnowledgeAnswerActivity.get()); + } else if (activity == Activity.KNOWLEDGE_EVENT_ADD) { + array.add(KnowledgeEventActivity.get()); + } else if (activity == Activity.COMMENT_INSERT) { + array.add(CommentInsertActivity.get()); + } else if (activity == Activity.COMMENT_LIKE) { + array.add(CommentLikeActivity.get()); + } + return array; + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + private void execute(Activity activity, LoginedUser eventUser, Date eventDateTime, KnowledgesEntity knowledge, CommentsEntity comment) { + List processors = this.getActivityProcessors(activity); + for (ActivityProcessor activityProcessor : processors) { + if (activityProcessor instanceof AbstractActivityProcessor) { + AbstractActivityProcessor processor = (AbstractActivityProcessor) activityProcessor; + processor.setEventUser(eventUser); + processor.setEventDateTime(eventDateTime); + } + if (activityProcessor instanceof AbstractAddPointForKnowledgeProcessor) { + if (knowledge == null) { + LOG.warn("bad parameter [knowledge], because it is null."); + continue; + } + AbstractAddPointForKnowledgeProcessor processor = (AbstractAddPointForKnowledgeProcessor) activityProcessor; + processor.setKnowledge(knowledge); + } else if (activityProcessor instanceof AbstractAddPointForCommentProcessor) { + if (comment == null) { + LOG.warn("bad parameter [comment], because it is null."); + continue; + } + AbstractAddPointForCommentProcessor processor = (AbstractAddPointForCommentProcessor) activityProcessor; + processor.setComment(comment); + } + if (activityProcessor instanceof AbstractActivityProcessor) { + AbstractActivityProcessor processor = (AbstractActivityProcessor) activityProcessor; + processor.setEventUser(eventUser); + processor.setEventDateTime(eventDateTime); + } + if (activityProcessor instanceof MultiActivityProcessor) { + MultiActivityProcessor processor = (MultiActivityProcessor) activityProcessor; + processor.setActivity(activity); + } + try { + activityProcessor.execute(); + } catch (Exception e) { + // Activity処理は失敗しても、いったん無視する + LOG.error("error", e); + } + } + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void processActivity(Activity activity, LoginedUser eventUser, Date eventDateTime) { + execute(activity, eventUser, eventDateTime, null, null); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void processActivity(Activity activity, LoginedUser eventUser, Date eventDateTime, KnowledgesEntity knowledge) { + execute(activity, eventUser, eventDateTime, knowledge, null); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void processActivity(Activity activity, LoginedUser eventUser, Date eventDateTime, CommentsEntity comment) { + execute(activity, eventUser, eventDateTime, null, comment); + } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void processKnowledgeSaveActivity(LoginedUser eventUser, Date eventDateTime, KnowledgesEntity knowledge) { + Activity activity = null; + int publicFlag = KnowledgeLogic.PUBLIC_FLAG_PRIVATE; + if (knowledge.getPublicFlag() != null) { + publicFlag = knowledge.getPublicFlag(); + } + if (publicFlag == KnowledgeLogic.PUBLIC_FLAG_PUBLIC) { + activity = Activity.KNOWLEDGE_POST_PUBLIC; + } else if (publicFlag == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { + activity = Activity.KNOWLEDGE_POST_PROTECTED; + } else if (publicFlag == KnowledgeLogic.PUBLIC_FLAG_PRIVATE) { + activity = Activity.KNOWLEDGE_POST_PRIVATE; + } + if (activity == null) { + LOG.warn("invalid public flag. knowledge[]" + knowledge.getKnowledgeId()); + return; + } + execute(activity, eventUser, eventDateTime, knowledge, null); + } + + public List getUserPointHistoriesByDate(Integer userId, UserConfigs userConfigs) { + return PointUserHistoriesDao.get().selectPointHistoriesByDate(userId, userConfigs); + } + + private String getDisplayDate(Date date, UserConfigs userConfigs) { + return DateConvertLogic.get().convertDate(date, userConfigs.getLocale(), userConfigs.getTimezoneOffset()); + } + private String convKnowledgeLink(String systemUrl, String target) { + StringBuilder builder = new StringBuilder(); + builder.append("#"); + builder.append(target); + builder.append(""); + return builder.toString(); + } + private String convUserLink(String systemUrl, Integer userID, String userName) { + StringBuilder builder = new StringBuilder(); + builder.append(""); + builder.append(HtmlUtils.escapeHTML(userName)); + builder.append(""); + return builder.toString(); + } + private String getActivityMsg(PointUserHistoriesEntity history, Map activities, UserConfigs userConfigs, String systemUrl) { + Resources resources = Resources.getInstance(userConfigs.getLocale()); + ActivitiesEntity activity = activities.get(history.getActivityNo()); + if (activity == null) { + return ""; + } + if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_INSERT) { + return resources.getResource("knowledge.activity.type.11.do.insert", convKnowledgeLink(systemUrl, activity.getTarget())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_SHOW) { + return resources.getResource("knowledge.activity.type.21.do.show", convKnowledgeLink(systemUrl, activity.getTarget())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_SHOWN_BY_OHER) { + return resources.getResource("knowledge.activity.type.22.shown", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_LIKE) { + return resources.getResource("knowledge.activity.type.31.do.like", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_LIKED_BY_OHER) { + return resources.getResource("knowledge.activity.type.32.liked", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_STOCK) { + return resources.getResource("knowledge.activity.type.41.do.stock", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_STOCKED_BY_OHER) { + return resources.getResource("knowledge.activity.type.42.stocked", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_ANSWER) { + return resources.getResource("knowledge.activity.type.51.do.ansewer", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_ANSWERD_BY_OHER) { + return resources.getResource("knowledge.activity.type.52.answered", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_JOIN_EVENT) { + return resources.getResource("knowledge.activity.type.61.do.join", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_JOINED_BY_OHER) { + return resources.getResource("knowledge.activity.type.62.joined", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_POST_PUBLIC) { + return resources.getResource("knowledge.activity.type.101.do.post.public", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_POST_PROTECT) { + return resources.getResource("knowledge.activity.type.111.do.post.protect", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_POST_PRIVATE) { + return resources.getResource("knowledge.activity.type.121.do.post.private", convKnowledgeLink(systemUrl, activity.getTarget()), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + + } else if (history.getType() >= ActivityProcessor.TYPE_COMMENT_DO_INSERT) { + CommentsEntity comment = CommentsDao.get().selectOnKey(new Long(activity.getTarget())); + if (comment != null) { + if (history.getType() == ActivityProcessor.TYPE_COMMENT_DO_INSERT) { + return resources.getResource("knowledge.activity.type.1011.do.comment.insert", + convKnowledgeLink(systemUrl, String.valueOf(comment.getKnowledgeId())), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_COMMENT_DO_LIKE) { + return resources.getResource("knowledge.activity.type.1031.do.comment.like", + convKnowledgeLink(systemUrl, String.valueOf(comment.getKnowledgeId())), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } else if (history.getType() == ActivityProcessor.TYPE_COMMENT_LIKED_BY_OHER) { + return resources.getResource("knowledge.activity.type.1032.comment.liked", + convKnowledgeLink(systemUrl, String.valueOf(comment.getKnowledgeId())), + convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName())); + } + } + } + return ""; + } + + public List getUserPointHistoriese(Integer userId, int limit, int offset, UserConfigs userConfigs) { + List histories = PointUserHistoriesDao.get().selectOnUser(userId, limit, offset, Order.DESC); + List activityNos = new ArrayList<>(); + for (PointUserHistoriesEntity history : histories) { + activityNos.add(history.getActivityNo()); + } + List activityList = ActivitiesDao.get().selectOnNos(activityNos); + Map activities = new HashMap<>(); + for (ActivitiesEntity activitiesEntity : activityList) { + activities.put(activitiesEntity.getActivityNo(), activitiesEntity); + } + + SystemConfigsDao dao = SystemConfigsDao.get(); + SystemConfigsEntity config = dao.selectOnKey(SystemConfig.SYSTEM_URL, AppConfig.get().getSystemName()); + StringBuilder builder = new StringBuilder(); + if (config != null) { + builder.append(config.getConfigValue()); + if (!config.getConfigValue().endsWith("/")) { + builder.append("/"); + } + } + List list = new ArrayList<>(); + for (PointUserHistoriesEntity history : histories) { + String msg = getActivityMsg(history, activities, userConfigs, builder.toString()); + if (StringUtils.isNotEmpty(msg)) { + ActivityHistory activity = new ActivityHistory(); + activity.setDate(history.getInsertDatetime()); + activity.setDispDate(getDisplayDate(history.getInsertDatetime(), userConfigs)); + activity.setMsg(msg); + list.add(activity); + } + } + return list; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/ActivityProcessor.java b/src/main/java/org/support/project/knowledge/logic/activity/ActivityProcessor.java new file mode 100644 index 000000000..e28df5526 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/ActivityProcessor.java @@ -0,0 +1,36 @@ +package org.support.project.knowledge.logic.activity; + +public interface ActivityProcessor { + public static final int TYPE_KNOWLEDGE_DO_INSERT = 11; + public static final int TYPE_KNOWLEDGE_INSERTED = 13; + public static final int TYPE_KNOWLEDGE_DO_SHOW = 21; + public static final int TYPE_KNOWLEDGE_SHOWN_BY_OHER = 22; + public static final int TYPE_KNOWLEDGE_SHOWN = 23; + public static final int TYPE_KNOWLEDGE_DO_LIKE = 31; + public static final int TYPE_KNOWLEDGE_LIKED_BY_OHER = 32; + public static final int TYPE_KNOWLEDGE_LIKED = 33; + public static final int TYPE_KNOWLEDGE_DO_STOCK = 41; + public static final int TYPE_KNOWLEDGE_STOCKED_BY_OHER = 42; + public static final int TYPE_KNOWLEDGE_STOCKED = 43; + public static final int TYPE_KNOWLEDGE_DO_ANSWER = 51; + public static final int TYPE_KNOWLEDGE_ANSWERD_BY_OHER = 52; + public static final int TYPE_KNOWLEDGE_ANSWERD = 53; + public static final int TYPE_KNOWLEDGE_DO_JOIN_EVENT = 61; + public static final int TYPE_KNOWLEDGE_JOINED_BY_OHER = 62; + public static final int TYPE_KNOWLEDGE_JOINED = 63; + + public static final int TYPE_KNOWLEDGE_DO_POST_PUBLIC = 101; + public static final int TYPE_KNOWLEDGE_POSTED_PUBLIC = 103; + public static final int TYPE_KNOWLEDGE_DO_POST_PROTECT = 111; + public static final int TYPE_KNOWLEDGE_POSTED_PROTECT = 113; + public static final int TYPE_KNOWLEDGE_DO_POST_PRIVATE = 121; + public static final int TYPE_KNOWLEDGE_POSTED_PRIVATE = 123; + + public static final int TYPE_COMMENT_DO_INSERT = 1011; + public static final int TYPE_COMMENT_INSERTED = 1013; + public static final int TYPE_COMMENT_DO_LIKE = 1031; + public static final int TYPE_COMMENT_LIKED_BY_OHER = 1032; + public static final int TYPE_COMMENT_LIKED = 1033; + + void execute() throws Exception; +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/CommentInsertActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/CommentInsertActivity.java new file mode 100644 index 000000000..e8521aebf --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/CommentInsertActivity.java @@ -0,0 +1,95 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.logic.KnowledgeLogic; + +/** + * + * 101 | 1011 | 登録者 | 20 | コメントを投稿すると、投稿者にポイント追加 + * 101 | 1012 | 記事 | 20 | 記事にコメントが付くと、その記事に対しポイント追加 + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class CommentInsertActivity extends AbstractAddPointForCommentProcessor { + private static final Log LOG = LogFactory.getLog(CommentInsertActivity.class); + public static CommentInsertActivity get() { + return Container.getComp(CommentInsertActivity.class); + } + + private int point = 0; + + private int getKnowledgePoint() { + if (getParentKnowledge().getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PRIVATE) { + // 非公開の記事にポイントをつけてもポイントにはならない + return 0; + } + int point = 0; + if (getParentKnowledge().getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PUBLIC) { + point = 20; + } else if (getParentKnowledge().getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { + point = 10; + } + return point; + } + + private int getPoint() { + if (point != 0) { + return point; + } + if (getParentKnowledge().getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PRIVATE) { + // 非公開の記事にポイントをつけてもポイントにはならない + return 0; + } + // 指定の記事に登録した、ユニークなユーザ数によりポイントを変える + int point = getKnowledgePoint(); + long count = CommentsDao.get().selectUniqueUserCountOnKnowledgeId(getComment().getKnowledgeId()); + int add = 0; + if (count > 100) { + add = 1000; + } else if (count > 100){ + add = ((int) count - 100 ) / 2; // 100人を超えると、2人毎に1ポイント増えるようになる + } else if (count > 10){ + add = (int) count / 5; // 5人を超えると、ポイントが増える(5人毎に1ポイント) + int[] points = {1,1,1,1,1,2,2,2,2,3}; + add += points[RandomUtil.randamNum(0, 10)]; // ランダムで値が増減するボーナスポイント + } + point += add; + this.point = point; + return point; + } + + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on add comment knowledge."); + return Activity.COMMENT_INSERT; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + int point = getKnowledgePoint(); + if (point == 0) { + return null; + } + return new TypeAndPoint(TYPE_COMMENT_DO_INSERT, point); + } + @Override + protected TypeAndPoint getTypeAndPointForCommentOwner() { + return null; + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + int point = getPoint(); + if (point == 0) { + return null; + } + return new TypeAndPoint(TYPE_COMMENT_INSERTED, point); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/CommentLikeActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/CommentLikeActivity.java new file mode 100644 index 000000000..f03beb918 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/CommentLikeActivity.java @@ -0,0 +1,82 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.ActivitiesDao; + +/** + * + * 103 | 1031 | 参照者 | 2 | イイネを押すと、押した人にポイント追加 + * 103 | 1032 | 登録者 | 10 | コメントにイイネが付くと、そのコメントを登録したユーザにポイントが付く + * 103 | 1033 | 記事 | 10 | コメントにイイネがつくと、そのコメントの記事に対しポイント追加 + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class CommentLikeActivity extends AbstractAddPointForCommentProcessor { + private static final Log LOG = LogFactory.getLog(CommentLikeActivity.class); + public static CommentLikeActivity get() { + return Container.getComp(CommentLikeActivity.class); + } + + private int point = 0; + + private int getPoint() { + if (point != 0) { + return point; + } + // 指定のコメントについたイイネの件数(ユニーク件数)でポイントを増やす + int point = 10; + long count = ActivitiesDao.get().selectCountByTarget( + getActivity().getValue(), getComment().getCommentNo()); + int add = 0; + if (count > 100) { + add = 1000; + } else if (count > 100){ + add = ((int) count - 100 ) / 2; // 100人を超えると、2人毎に1ポイント増えるようになる + } else if (count > 10){ + add = (int) count / 5; // 5人を超えると、ポイントが増える(5人毎に1ポイント) + int[] points = {1,1,1,1,1,2,2,2,2,3}; + add += points[RandomUtil.randamNum(0, 10)]; // ランダムで値が増減するボーナスポイント + } + if (LOG.isDebugEnabled()) { + LOG.debug("[Bonus point]: " + add + " [COUNT]:" + count); + } + point += add; + this.point = point; + return point; + } + + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on add comment knowledge."); + return Activity.COMMENT_LIKE; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + if (eventUser.getUserId().intValue() == getComment().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_COMMENT_DO_LIKE, 2); + } + @Override + protected TypeAndPoint getTypeAndPointForCommentOwner() { + if (eventUser.getUserId().intValue() == getComment().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_COMMENT_LIKED_BY_OHER, getPoint()); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + if (eventUser.getUserId().intValue() == getParentKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_COMMENT_LIKED, getPoint()); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeAnswerActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeAnswerActivity.java new file mode 100644 index 000000000..773c3240c --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeAnswerActivity.java @@ -0,0 +1,59 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * + * 5 | 51 | 参照者 | 3 | アンケート回答者にポイント付与 + * 5 | 52 | 記事登録者 | 3 | 記事の登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 5 | 53 | 記事 | 3 | 記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeAnswerActivity extends AbstractAddPointForKnowledgeProcessor { + private static final Log LOG = LogFactory.getLog(KnowledgeAnswerActivity.class); + public static KnowledgeAnswerActivity get() { + return Container.getComp(KnowledgeAnswerActivity.class); + } + + private int point = 0; + private int getPoint() { + if (point != 0) { + return point; + } + //int[] points = {1,1,2,2,2,2,3,3,3,4}; + //this.point = points[RandomUtil.randamNum(0, 10)]; // ランダムで値を増減してみた + this.point = 3; + return point; + } + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on answer knowledge."); + return Activity.KNOWLEDGE_ANSWER; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + return new TypeAndPoint(TYPE_KNOWLEDGE_DO_ANSWER, 3); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledgeOwner() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_ANSWERD_BY_OHER, getPoint()); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_ANSWERD, getPoint()); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeEventActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeEventActivity.java new file mode 100644 index 000000000..2d3abc4d3 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeEventActivity.java @@ -0,0 +1,76 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.ActivitiesDao; + +/** + * + * 6 | 61 | 参照者 | 5 | イベント参加者にポイント付与 + * 6 | 62 | 記事登録者 | 5 | 記事の登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 6 | 63 | 記事 | 5 | 記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeEventActivity extends AbstractAddPointForKnowledgeProcessor { + private static final Log LOG = LogFactory.getLog(KnowledgeEventActivity.class); + public static KnowledgeEventActivity get() { + return Container.getComp(KnowledgeEventActivity.class); + } + + private int point = 0; + + private int getPoint() { + if (point != 0) { + return point; + } + // 参加者人数により増減 + int point = 5; + long count = ActivitiesDao.get().selectCountByTarget( + getActivity().getValue(), getKnowledge().getKnowledgeId()); + int add = 0; + if (count > 100) { + add = 1000; + } else if (count > 100){ + add = ((int) count - 100 ) / 2; // 100人を超えると、2人毎に1ポイント増えるようになる + } else if (count > 10){ + add = (int) count / 5; // 5人を超えると、ポイントが増える(5人毎に1ポイント) + int[] points = {1,1,1,1,1,2,2,2,2,3}; + add += points[RandomUtil.randamNum(0, 10)]; // ランダムで値が増減するボーナスポイント + } + if (LOG.isDebugEnabled()) { + LOG.debug("[Bonus point]: " + add + " [COUNT]:" + count); + } + point += add; + this.point = point; + return point; + } + + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on event knowledge."); + return Activity.KNOWLEDGE_EVENT_ADD; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + return new TypeAndPoint(TYPE_KNOWLEDGE_DO_JOIN_EVENT, 5); // 参加者には固定のポイント + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledgeOwner() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_JOINED_BY_OHER, getPoint()); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + return new TypeAndPoint(TYPE_KNOWLEDGE_JOINED, getPoint()); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeLikeActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeLikeActivity.java new file mode 100644 index 000000000..ae8590e58 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeLikeActivity.java @@ -0,0 +1,78 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.ActivitiesDao; + +/** + * + * 3 | 31 | 参照者 | 2 | 記事にイイネのアクションを行うと、参照者にポイント追加(一つの記事に付き1回のみ) + * 3 | 32 | 記事登録者 | 10 | 自分が登録された記事にイイネがついたら、登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 3 | 33 | 記事 | 10 | 記事が参照されると、その記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeLikeActivity extends AbstractAddPointForKnowledgeProcessor { + private static final Log LOG = LogFactory.getLog(KnowledgeLikeActivity.class); + public static KnowledgeLikeActivity get() { + return Container.getComp(KnowledgeLikeActivity.class); + } + + private int point = 0; + + private int getPoint() { + if (point != 0) { + return point; + } + // ユニークユーザのイイネ件数によりポイントを増やす + int point = 10; + long count = ActivitiesDao.get().selectCountByTarget( + getActivity().getValue(), getKnowledge().getKnowledgeId()); + int add = 0; + if (count > 100) { + add = 1000; + } else if (count > 100){ + add = ((int) count - 100 ) / 2; // 100人を超えると、2人毎に1ポイント増えるようになる + } else if (count > 10){ + add = (int) count / 5; // 5人を超えると、ポイントが増える(5人毎に1ポイント) + int[] points = {1,1,1,1,1,2,2,2,2,3}; + add += points[RandomUtil.randamNum(0, 10)]; // ランダムで値が増減するボーナスポイント + } + if (LOG.isDebugEnabled()) { + LOG.debug("[Bonus point]: " + add + " [COUNT]:" + count); + } + point += add; + this.point = point; + return point; + } + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on like knowledge."); + return Activity.KNOWLEDGE_LIKE; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + return new TypeAndPoint(TYPE_KNOWLEDGE_DO_LIKE, 2); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledgeOwner() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_LIKED_BY_OHER, getPoint()); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_LIKED, getPoint()); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeSaveActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeSaveActivity.java new file mode 100644 index 000000000..1f3cc61d1 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeSaveActivity.java @@ -0,0 +1,101 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.PointKnowledgeHistoriesDao; + +/** + * ナレッジ投稿時のポイント付与 + * 過去の投稿の公開区分によって、今回獲得するポイントが変化する + * + * 種類 | 獲得のタイプ | ポイント付与先 | ポイント | 獲得タイプの意味 + * 10 | 101 | 記事登録者 | 50 | 公開になった時点でトータル50になるように + * 10 | 103 | 記事 | 50 | + * 11 | 111 | 記事登録者 | 30 | + * 11 | 113 | 記事 | 30 | + * 12 | 121 | 記事登録者 | 0 | このアクティビティの前に、投稿のアクティビティがあった場合、それを打ち消す(マイナスのポイント) + * 12 | 123 | 記事 | 0 | + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeSaveActivity extends AbstractAddPointForKnowledgeProcessor implements MultiActivityProcessor { + private static final Log LOG = LogFactory.getLog(KnowledgeSaveActivity.class); + public static KnowledgeSaveActivity get() { + return Container.getComp(KnowledgeSaveActivity.class); + } + private Activity activity; + public void setActivity(Activity activity) { + this.activity = activity; + } + @Override + protected Activity getActivity() { + LOG.debug("Activity process start. " + activity.toString()); + return activity; + } + private int point = 0; + private int getKindPoint(int kind) { + if (kind == Activity.KNOWLEDGE_POST_PUBLIC.getValue()) { + return 50; + } else if (kind == Activity.KNOWLEDGE_POST_PROTECTED.getValue()) { + return 30; + } + return 0; + } + private int getPoint() { + if (point != 0) { + return point; + } + int beforePoint = PointKnowledgeHistoriesDao.get().selectBeforePoint( + getKnowledge().getKnowledgeId(), TYPE_KNOWLEDGE_POSTED_PUBLIC, TYPE_KNOWLEDGE_POSTED_PROTECT, TYPE_KNOWLEDGE_POSTED_PRIVATE); + int nowPoint = getKindPoint(getActivity().getValue()); + point = nowPoint - beforePoint; + if (LOG.isDebugEnabled()) { + LOG.debug("[ID]" + getKnowledge().getKnowledgeId() + "[POINT NOW]" + nowPoint + " [POINT BEFORE]" + beforePoint + " [ADD RESULT]" + point); + } + return point; + } + private int getTypeForExecuter() { + if (getActivity() == Activity.KNOWLEDGE_POST_PUBLIC) { + return TYPE_KNOWLEDGE_DO_POST_PUBLIC; + } else if (getActivity() == Activity.KNOWLEDGE_POST_PROTECTED) { + return TYPE_KNOWLEDGE_DO_POST_PROTECT; + } else if (getActivity() == Activity.KNOWLEDGE_POST_PRIVATE) { + return TYPE_KNOWLEDGE_DO_POST_PRIVATE; + } + return -1; + } + private int getTypeForKnowledge() { + if (getActivity() == Activity.KNOWLEDGE_POST_PUBLIC) { + return TYPE_KNOWLEDGE_POSTED_PUBLIC; + } else if (getActivity() == Activity.KNOWLEDGE_POST_PROTECTED) { + return TYPE_KNOWLEDGE_POSTED_PROTECT; + } else if (getActivity() == Activity.KNOWLEDGE_POST_PRIVATE) { + return TYPE_KNOWLEDGE_POSTED_PRIVATE; + } + return -1; + } + + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + int point = getPoint(); + if (point == 0) { + return null; + } + return new TypeAndPoint(getTypeForExecuter(), point); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledgeOwner() { + return null; + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + int point = getPoint(); + if (point == 0) { + return null; + } + return new TypeAndPoint(getTypeForKnowledge(), point); + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeShowActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeShowActivity.java new file mode 100644 index 000000000..02242d665 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeShowActivity.java @@ -0,0 +1,72 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.ActivitiesDao; + +/** + * + * 種類 | 獲得のタイプ | ポイント付与先 | ポイント | 獲得タイプの意味 + * 2 | 21 | 参照者 | 1 | 記事を参照するアクションを行うと、参照者にポイント追加(一つの記事に付き1回のみ) + * 2 | 22 | 記事登録者 | 1 | 自分が登録された記事が参照されたら、登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 2 | 23 | 記事 | 1 | 記事が参照されると、その記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeShowActivity extends AbstractAddPointForKnowledgeProcessor { + private static final Log LOG = LogFactory.getLog(KnowledgeShowActivity.class); + public static KnowledgeShowActivity get() { + return Container.getComp(KnowledgeShowActivity.class); + } + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on show knowledge."); + return Activity.KNOWLEDGE_SHOW; + } + private int getPoint() { + // ユニークな参照者が多くなると、ポイントが増えるように調整(投稿数が少なくても、良い記事を書けばポイントが高くなる) + int point = 1; + long count = ActivitiesDao.get().selectCountByTarget( + getActivity().getValue(), getKnowledge().getKnowledgeId()); + int add = 0; + if (count > 1000) { + add = 100; // 1000 人以上だと100固定 + } else if (count > 100){ + add = 10 + ((int) count - 100) / 15; // 100人を超えると、20人毎に1ポイント増えるようになる + } else if (count > 10){ + add = ((int) count) / 10; // 10人を超えると、ポイントが増える(10人毎に1ポイント) + } + if (LOG.isDebugEnabled()) { + LOG.debug("[Bonus point]: " + add + " [COUNT]:" + count); + } + point += add; + return point; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_DO_SHOW, 1); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledgeOwner() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_SHOWN_BY_OHER, getPoint()); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_SHOWN, getPoint()); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeStockActivity.java b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeStockActivity.java new file mode 100644 index 000000000..200078cb6 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/KnowledgeStockActivity.java @@ -0,0 +1,61 @@ +package org.support.project.knowledge.logic.activity; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * + * 4 | 41 | 参照者 | 0 | ストックした場合、ストックした人にポイントは付与しない + * 4 | 42 | 記事登録者 | 2 | 記事の登録者にポイント追加(一つの記事に対し、参照者毎に1回のみ) + * 4 | 43 | 記事 | 2 | 記事のポイントが追加(一つの記事に対し、参照者毎に1回のみ) + * + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeStockActivity extends AbstractAddPointForKnowledgeProcessor { + private static final Log LOG = LogFactory.getLog(KnowledgeStockActivity.class); + public static KnowledgeStockActivity get() { + return Container.getComp(KnowledgeStockActivity.class); + } + + private int point = 0; + + private int getPoint() { + if (point != 0) { + return point; + } +// int[] points = {1,1,1,1,1,2,2,2,2,3}; +// this.point = points[RandomUtil.randamNum(0, 10)]; // ランダムで値を増減してみた + this.point = 2; + return point; + } + + + @Override + protected Activity getActivity() { + LOG.debug("Start add point process on stock knowledge."); + return Activity.KNOWLEDGE_STOCK; + } + @Override + protected TypeAndPoint getTypeAndPointForActivityExecuter() { + return null; + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledgeOwner() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_STOCKED_BY_OHER, getPoint()); + } + @Override + protected TypeAndPoint getTypeAndPointForKnowledge() { + if (eventUser.getUserId().intValue() == getKnowledge().getInsertUser().intValue()) { + return null; + } + return new TypeAndPoint(TYPE_KNOWLEDGE_STOCKED, getPoint()); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/activity/MultiActivityProcessor.java b/src/main/java/org/support/project/knowledge/logic/activity/MultiActivityProcessor.java new file mode 100644 index 000000000..7bff43fb5 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/activity/MultiActivityProcessor.java @@ -0,0 +1,12 @@ +package org.support.project.knowledge.logic.activity; + + +/** + * 通常のActivityProcessorは、単一のActivityを処理することを想定しているが、 + * 複数のActivityを一つのクラスで処理してしまいたいこともある。 + * この場合、どのActivityとして呼び出されたかを保持する必要があるので、Activityを外部からセットするIFを持つ + * @author koda + */ +public interface MultiActivityProcessor { + void setActivity(Activity activity); +} diff --git a/src/main/java/org/support/project/knowledge/logic/hook/BeforeSavePointHook.java b/src/main/java/org/support/project/knowledge/logic/hook/BeforeSavePointHook.java new file mode 100644 index 000000000..00e40c088 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/hook/BeforeSavePointHook.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.logic.hook; + +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.vo.KnowledgeData; +import org.support.project.web.bean.LoginedUser; + +@DI(instance = Instance.Singleton) +public class BeforeSavePointHook implements BeforeSaveHook { + + @Override + public void beforeSave(KnowledgeData data, KnowledgesEntity db, LoginedUser loginedUser) throws Exception { + if (data.getKnowledge().getKnowledgeId() == null) { + // 新規登録 + data.getKnowledge().setPoint(0); + } else { + data.getKnowledge().setPoint(db.getPoint()); // ポイントは、現在のDBの値をコピー + } + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/hook/HookFactory.java b/src/main/java/org/support/project/knowledge/logic/hook/HookFactory.java index 5b6e827ac..cdd4f0298 100644 --- a/src/main/java/org/support/project/knowledge/logic/hook/HookFactory.java +++ b/src/main/java/org/support/project/knowledge/logic/hook/HookFactory.java @@ -22,6 +22,7 @@ public static List getBeforeSaveHookInstance(KnowledgeData knowl hooks.add(Container.getComp(BeforeSaveOldEventRemoveHook.class)); } } + hooks.add(Container.getComp(BeforeSavePointHook.class)); return hooks; } diff --git a/src/main/java/org/support/project/knowledge/logic/notification/AbstractEventNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/AbstractEventNotification.java new file mode 100644 index 000000000..4bc0f435b --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/AbstractEventNotification.java @@ -0,0 +1,265 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.knowledge.dao.EventsDao; +import org.support.project.knowledge.dao.KnowledgeItemValuesDao; +import org.support.project.knowledge.dao.ParticipantsDao; +import org.support.project.knowledge.dao.StockKnowledgesDao; +import org.support.project.knowledge.entity.EventsEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.entity.ParticipantsEntity; +import org.support.project.knowledge.entity.StockKnowledgesEntity; +import org.support.project.knowledge.logic.EventsLogic; +import org.support.project.knowledge.logic.MailEventLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.knowledge.vo.notification.EventInformation; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +public abstract class AbstractEventNotification extends AbstractNotification implements EventNotification { + public static final String TEMPLATE_EVENT_SOON = "knowledge.event.label.timing.soon"; + public static final String TEMPLATE_EVENT_TODAY = "knowledge.event.label.timing.tody"; + public static final String TEMPLATE_EVENT_WEEK = "knowledge.event.label.timing.week"; + + /** ログ */ + private static final Log LOG = LogFactory.getLog(AbstractEventNotification.class); + + protected static final int NOTIFY_STATUS_NOT_SEND = MailEventLogic.NOTIFY_STATUS_NOT_SEND; + /** 今週のイベント通知(日曜に通知) */ + protected static final int NOTIFY_STATUS_BEFORE_WEEK = MailEventLogic.NOTIFY_STATUS_BEFORE_WEEK; + /** 本日のイベント通知 */ + protected static final int NOTIFY_STATUS_BEFORE_DATE = MailEventLogic.NOTIFY_STATUS_BEFORE_DATE; + /** 30分前のイベント通知 */ + protected static final int NOTIFY_STATUS_BEFORE_MIN = MailEventLogic.NOTIFY_STATUS_BEFORE_MIN; + /** ステータス:ストック中 */ + protected static final int STATUS_STOCKED = MailEventLogic.STATUS_STOCKED; + + protected void sendNotify(EventsEntity event, KnowledgesEntity knowledge, List values, int timing) { + // 画面での通知の情報を登録 + NotificationsEntity notification = insertNotification(event, knowledge, values, timing); + + List userIds = new ArrayList<>(); + // 参加者に通知 + List participants = ParticipantsDao.get().selectOnKnowledgeId(event.getKnowledgeId()); + for (ParticipantsEntity participant : participants) { + if (!userIds.contains(participant.getUserId())) { + UsersEntity user = UsersDao.get().selectOnKey(participant.getUserId()); + if (user != null) { + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, user); + + this.sendNotifyEvent(event, knowledge, values, user, participant.getStatus(), timing); + userIds.add(participant.getUserId()); + } + } + } + // ストックに入れているユーザに通知 + List stocks = StockKnowledgesDao.get().selectOnKnowledgeId(event.getKnowledgeId()); + for (StockKnowledgesEntity stockKnowledgesEntity : stocks) { + if (!userIds.contains(stockKnowledgesEntity.getInsertUser())) { + UsersEntity user = UsersDao.get().selectOnKey(stockKnowledgesEntity.getInsertUser()); + if (user != null) { + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, user); + + this.sendNotifyEvent(event, knowledge, values, user, STATUS_STOCKED, timing); + userIds.add(stockKnowledgesEntity.getInsertUser()); + } + } + } + event.setNotifyStatus(timing); + EventsDao.get().save(event); + } + + + private NotificationsEntity insertNotification(EventsEntity event, KnowledgesEntity knowledge, List values, + int timing) { + // 通知情報を作成 + NotificationsEntity notification = new NotificationsEntity(); + // フォーマットのテンプレート + notification.setTitle(MailLogic.NOTIFY_EVENT); + EventInformation info = new EventInformation(); + info.setKnowledgeId(knowledge.getKnowledgeId()); + info.setKnowledgeTitle(knowledge.getTitle()); + info.setUpdateUser(knowledge.getUpdateUserName()); + info.setTiming(timing); + notification.setContent(JSON.encode(info)); + notification = NotificationsDao.get().insert(notification); + return notification; + } + + + private void sendNotifyEvent(EventsEntity event, KnowledgesEntity knowledge, List values, + UsersEntity user, int status, int timing) { + if (!StringUtils.isEmailAddress(user.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + user.getMailAddress() + "] is wrong."); + return; + } + MailLocaleTemplatesEntity template = MailLogic.get().load(user.getLocale(), MailLogic.NOTIFY_EVENT); + + String date = ""; + String start = ""; + String end = ""; + String place = ""; + for (KnowledgeItemValuesEntity item : values) { + if (item.getItemNo() == EventsLogic.ITEM_NO_DATE) { + date = item.getItemValue(); + } else if (item.getItemNo() == EventsLogic.ITEM_NO_START) { + start = item.getItemValue(); + } else if (item.getItemNo() == EventsLogic.ITEM_NO_END) { + end = item.getItemValue(); + } else if (item.getItemNo() == EventsLogic.ITEM_NO_PLACE) { + place = item.getItemValue(); + } + } + Resources resources = Resources.getInstance(user.getLocale()); + String statusLabel = ""; + if (status == EventsLogic.STATUS_PARTICIPATION) { + statusLabel = resources.getResource("knowledge.event.label.status.participation"); + } else if (status == EventsLogic.STATUS_WAIT_CANSEL) { + statusLabel = resources.getResource("knowledge.event.label.status.wait.cansel"); + } else if (status == STATUS_STOCKED) { + statusLabel = resources.getResource("knowledge.event.label.status.stocked"); + } + String timingLabel = ""; + if (timing == NOTIFY_STATUS_BEFORE_WEEK) { + timingLabel = resources.getResource(TEMPLATE_EVENT_WEEK); + } else if (timing == NOTIFY_STATUS_BEFORE_DATE) { + timingLabel = resources.getResource(TEMPLATE_EVENT_TODAY); + } else if (timing == NOTIFY_STATUS_BEFORE_MIN) { + timingLabel = resources.getResource(TEMPLATE_EVENT_SOON); + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(user.getMailAddress()); + mailsEntity.setToName(user.getUserName()); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + title = title.replace("{Date}", date); + title = title.replace("{Start}", start); + title = title.replace("{End}", end); + title = title.replace("{Place}", place); + mailsEntity.setTitle(title); + + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + contents = contents.replace("{Date}", date); + contents = contents.replace("{Start}", start); + contents = contents.replace("{End}", end); + contents = contents.replace("{Place}", place); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + contents = contents.replace("{Status}", statusLabel); + contents = contents.replace("{Timing}", timingLabel); + contents = contents.replace("{UserName}", user.getUserName()); + mailsEntity.setContent(contents); + MailsDao.get().insert(mailsEntity); + } + + + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + String category = notificationsEntity.getTitle(); + EventInformation knowledge = JSON.decode(notificationsEntity.getContent(), EventInformation.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), category); + + List values = KnowledgeItemValuesDao.get().selectOnKnowledgeId(knowledge.getKnowledgeId()); + String date = ""; + String start = ""; + String end = ""; + String place = ""; + for (KnowledgeItemValuesEntity item : values) { + if (item.getItemNo() == EventsLogic.ITEM_NO_DATE) { + date = item.getItemValue(); + } else if (item.getItemNo() == EventsLogic.ITEM_NO_START) { + start = item.getItemValue(); + } else if (item.getItemNo() == EventsLogic.ITEM_NO_END) { + end = item.getItemValue(); + } else if (item.getItemNo() == EventsLogic.ITEM_NO_PLACE) { + place = item.getItemValue(); + } + } + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", String.valueOf(knowledge.getKnowledgeId())); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getKnowledgeTitle(), 80)); + title = title.replace("{Date}", date); + title = title.replace("{Start}", start); + title = title.replace("{End}", end); + title = title.replace("{Place}", place); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + EventsEntity event = EventsDao.get().selectOnKey(knowledge.getKnowledgeId()); + if (event == null) { + return; + } + int status = -1; + ParticipantsEntity participant = ParticipantsDao.get().selectOnKey(knowledge.getKnowledgeId(), loginedUser.getUserId()); + if (participant != null) { + status = participant.getStatus(); + } else { + // 予約が入っていないということは、ストックしたもの + status = STATUS_STOCKED; + } + + Resources resources = Resources.getInstance(loginedUser.getLocale()); + String statusLabel = ""; + if (status == EventsLogic.STATUS_PARTICIPATION) { + statusLabel = resources.getResource("knowledge.event.label.status.participation"); + } else if (status == EventsLogic.STATUS_WAIT_CANSEL) { + statusLabel = resources.getResource("knowledge.event.label.status.wait.cansel"); + } else if (status == STATUS_STOCKED) { + statusLabel = resources.getResource("knowledge.event.label.status.stocked"); + } + + String timingLabel = ""; + int timing = knowledge.getTiming(); + if (timing == NOTIFY_STATUS_BEFORE_WEEK) { + timingLabel = resources.getResource(TEMPLATE_EVENT_WEEK); + } else if (timing == NOTIFY_STATUS_BEFORE_DATE) { + timingLabel = resources.getResource(TEMPLATE_EVENT_TODAY); + } else if (timing == NOTIFY_STATUS_BEFORE_MIN) { + timingLabel = resources.getResource(TEMPLATE_EVENT_SOON); + } + + + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", String.valueOf(knowledge.getKnowledgeId())); + contents = contents.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getKnowledgeTitle(), 80)); + contents = contents.replace("{Date}", date); + contents = contents.replace("{Start}", start); + contents = contents.replace("{End}", end); + contents = contents.replace("{Place}", place); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + contents = contents.replace("{Status}", statusLabel); + contents = contents.replace("{Timing}", timingLabel); + contents = contents.replace("{UserName}", loginedUser.getLoginUser().getUserName()); + notificationsEntity.setContent(contents); + } + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/AbstractNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/AbstractNotification.java new file mode 100644 index 000000000..e05f5affd --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/AbstractNotification.java @@ -0,0 +1,30 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.web.dao.UserNotificationsDao; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UserNotificationsEntity; + +public abstract class AbstractNotification implements Notification { + /** + * メール送信のIDを生成 + * @param string + * @return + */ + protected String idGen(String label) { + return MailLogic.get().idGen(label); + } + + /** + * 指定の通知をユーザに紐付け + * @param notification + * @param userId + */ + protected void insertUserNotification(NotificationsEntity notification, int userId) { + UserNotificationsEntity userNotification = new UserNotificationsEntity(notification.getNo(), userId); + userNotification.setStatus(NotificationLogic.STATUS_UNREAD); + UserNotificationsDao.get().insert(userNotification); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/AbstractParticipateNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/AbstractParticipateNotification.java new file mode 100644 index 000000000..36e52f272 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/AbstractParticipateNotification.java @@ -0,0 +1,102 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.common.config.Resources; +import org.support.project.common.util.StringUtils; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.EventsLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.knowledge.vo.notification.Participate; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.UserNotificationsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UserNotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +public abstract class AbstractParticipateNotification extends AbstractNotification implements ParticipateNotification { + + + protected void insertNotification(KnowledgesEntity knowledge, Integer participant, Integer status, String template) { + NotificationsEntity notification = new NotificationsEntity(); + notification.setTitle(template); + + Participate info = new Participate(); + info.setKnowledgeId(knowledge.getKnowledgeId()); + info.setKnowledgeTitle(knowledge.getTitle()); + info.setUpdateUser(knowledge.getUpdateUserName()); + + info.setParticipant(participant); + info.setStatus(status); + + notification.setContent(JSON.encode(info)); + notification = NotificationsDao.get().insert(notification); + + if (template.equals(MailLogic.NOTIFY_ADD_PARTICIPATE) || template.equals(MailLogic.NOTIFY_REMOVE_PARTICIPATE)) { + // 参加登録があったことを、開催者へ通知 / 参加キャンセルを開催者へ通知 + UserNotificationsEntity userNotification = new UserNotificationsEntity(notification.getNo(), knowledge.getInsertUser()); + userNotification.setStatus(NotificationLogic.STATUS_UNREAD); + UserNotificationsDao.get().insert(userNotification); + } else { + // 参加登録したことを、参加者へ通知 / キャンセル待ちのユーザに、参加登録になったことを通知 + UserNotificationsEntity userNotification = new UserNotificationsEntity(notification.getNo(), participant); + userNotification.setStatus(NotificationLogic.STATUS_UNREAD); + UserNotificationsDao.get().insert(userNotification); + } + } + + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + Participate info = JSON.decode(notificationsEntity.getContent(), Participate.class); + String templateString = notificationsEntity.getTitle(); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), notificationsEntity.getTitle()); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", String.valueOf(info.getKnowledgeId())); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(info.getKnowledgeTitle(), 80)); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", String.valueOf(info.getKnowledgeId())); + contents = contents.replace("{KnowledgeTitle}", info.getKnowledgeTitle()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(info.getKnowledgeId())); + UsersEntity participant = UsersDao.get().selectOnKey(info.getParticipant()); + if (participant != null) { + Resources resources = Resources.getInstance(loginedUser.getLocale()); + StringBuilder builder = new StringBuilder(); + int status = info.getStatus(); + if (MailLogic.NOTIFY_ADD_PARTICIPATE.equals(templateString) || MailLogic.NOTIFY_REMOVE_PARTICIPATE.equals(templateString)) { + // 参加登録があったことを、開催者へ通知 || 参加キャンセルを開催者へ通知 + builder.append(participant.getUserName()); + if (MailLogic.NOTIFY_ADD_PARTICIPATE.equals(templateString)) { + // 参加登録の場合、ステータスも表示 + if (status == EventsLogic.STATUS_PARTICIPATION) { + builder.append("[").append(resources.getResource("knowledge.view.label.status.participation")).append("]"); + } else { + builder.append("[").append(resources.getResource("knowledge.view.label.status.wait.cansel")).append("]"); + } + } + contents = contents.replace("{Participant}", builder.toString()); + } else { + // 参加登録したことを参加者へ通知 // キャンセル待ちの本登録の通知 + if (status == EventsLogic.STATUS_PARTICIPATION) { + builder.append(resources.getResource("knowledge.view.label.status.participation")); + } else { + builder.append(resources.getResource("knowledge.view.label.status.wait.cansel")); + } + contents = contents.replace("{Status}", builder.toString()); + } + } + notificationsEntity.setContent(contents); + } + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/AbstractQueueNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/AbstractQueueNotification.java new file mode 100644 index 000000000..db68fa2d2 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/AbstractQueueNotification.java @@ -0,0 +1,15 @@ +package org.support.project.knowledge.logic.notification; + +public abstract class AbstractQueueNotification extends AbstractNotification implements QueueNotification { + /** notify type */ + private int type; + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/AcceptCheckUserNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/AcceptCheckUserNotification.java new file mode 100644 index 000000000..bb9b8ad8f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/AcceptCheckUserNotification.java @@ -0,0 +1,126 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.List; +import java.util.Locale; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.config.WebConfig; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.ProvisionalRegistrationsEntity; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + + +/** + * 管理者へユーザの仮登録を通知(承認する必要があるため) + * @author koda + */ +@DI(instance = Instance.Singleton) +public class AcceptCheckUserNotification extends AbstractNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AcceptCheckUserNotification.class); + /** インスタンス取得 */ + public static AcceptCheckUserNotification get() { + return Container.getComp(AcceptCheckUserNotification.class); + } + + private static final String TEMPLATE = MailLogic.NOTIFY_ACCEPT_USER; + + private NotificationsEntity insertNotification(ProvisionalRegistrationsEntity registrationsEntity) { + NotificationsEntity notification = new NotificationsEntity(); + notification.setTitle(TEMPLATE); + notification.setContent(JSON.encode(registrationsEntity)); + notification = NotificationsDao.get().insert(notification); + return notification; + } + + /** + * 管理者へユーザの仮登録を通知(承認する必要があるため) + * + * @param entity + */ + public void sendNotifyAcceptUser(ProvisionalRegistrationsEntity registrationsEntity) { + LOG.trace("sendNotifyAcceptUser"); + SystemConfigsDao configsDao = SystemConfigsDao.get(); + SystemConfigsEntity configsEntity = configsDao.selectOnKey(SystemConfig.USER_ADD_NOTIFY, AppConfig.get().getSystemName()); + if (configsEntity != null && SystemConfig.USER_ADD_NOTIFY_ON.equals(configsEntity.getConfigValue())) { + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(org.support.project.knowledge.config.AppConfig.get().getSystemName()); + + // 通知の登録 + NotificationsEntity notification = insertNotification(registrationsEntity); + + // 管理者へのメール通知がONなので、メールを送信する + UsersDao usersDao = UsersDao.get(); + List users = usersDao.selectOnRoleKey(WebConfig.ROLE_ADMIN); + for (UsersEntity entity : users) { + // 通知を管理者ユーザに紐付け + insertUserNotification(notification, entity.getUserId()); + + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + return; + } + if (!StringUtils.isEmailAddress(entity.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + entity.getMailAddress() + "] is wrong."); + continue; + } + Locale locale = entity.getLocale(); + MailLocaleTemplatesEntity mailConfig = MailLogic.get().load(locale, TEMPLATE); + + String contents = mailConfig.getContent(); + contents = contents.replace("{UserKey}", registrationsEntity.getUserKey()); + contents = contents.replace("{UserName}", registrationsEntity.getUserName()); + + String title = mailConfig.getTitle(); + + MailsDao mailsDao = MailsDao.get(); + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(entity.getMailAddress()); + mailsEntity.setToName(entity.getUserName()); + mailsEntity.setTitle(title); + mailsEntity.setContent(contents); + mailsDao.insert(mailsEntity); + } + } + } + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + ProvisionalRegistrationsEntity user = JSON.decode(notificationsEntity.getContent(), ProvisionalRegistrationsEntity.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), notificationsEntity.getTitle()); + + String title = template.getTitle(); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{UserKey}", user.getUserKey()); + contents = contents.replace("{UserName}", user.getUserName()); + notificationsEntity.setContent(contents); + } + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/AddUserNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/AddUserNotification.java new file mode 100644 index 000000000..b88761599 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/AddUserNotification.java @@ -0,0 +1,128 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.List; +import java.util.Locale; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.config.WebConfig; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +/** + * 管理者へユーザが追加されたことを通知 + * @author koda + */ +@DI(instance = Instance.Singleton) +public class AddUserNotification extends AbstractNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AddUserNotification.class); + /** インスタンス取得 */ + public static AddUserNotification get() { + return Container.getComp(AddUserNotification.class); + } + + private static final String TEMPLATE = MailLogic.NOTIFY_ADD_USER; + + private NotificationsEntity insertNotification(UsersEntity user) { + NotificationsEntity notification = new NotificationsEntity(); + notification.setTitle(TEMPLATE); + user.setPassword(""); + notification.setContent(JSON.encode(user)); + notification = NotificationsDao.get().insert(notification); + return notification; + } + + /** + * 管理者へユーザが登録されたことを通知 + * + * @param user + */ + public void sendNotifyAddUser(UsersEntity user) { + LOG.trace("sendNotifyAddUser"); + SystemConfigsDao configsDao = SystemConfigsDao.get(); + SystemConfigsEntity configsEntity = configsDao.selectOnKey(SystemConfig.USER_ADD_NOTIFY, AppConfig.get().getSystemName()); + if (configsEntity != null && SystemConfig.USER_ADD_NOTIFY_ON.equals(configsEntity.getConfigValue())) { + // 通知の登録 + NotificationsEntity notification = insertNotification(user); + + // メール送信の設定のロード + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(org.support.project.knowledge.config.AppConfig.get().getSystemName()); + // 管理者へのメール通知がONなので、メールを送信する + UsersDao usersDao = UsersDao.get(); + List users = usersDao.selectOnRoleKey(WebConfig.ROLE_ADMIN); + for (UsersEntity entity : users) { + // 通知を管理者ユーザに紐付け + insertUserNotification(notification, entity.getUserId()); + + // メール送信するかチェック + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + continue; + } + if (!StringUtils.isEmailAddress(entity.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + entity.getMailAddress() + "] is wrong."); + continue; + } + Locale locale = entity.getLocale(); + MailLocaleTemplatesEntity mailConfig = MailLogic.get().load(locale, TEMPLATE); + + String contents = mailConfig.getContent(); + contents = contents.replace("{UserId}", String.valueOf(user.getUserId())); + contents = contents.replace("{UserName}", user.getUserName()); + contents = contents.replace("{UserMail}", user.getMailAddress()); + String title = mailConfig.getTitle(); + + MailsDao mailsDao = MailsDao.get(); + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(entity.getMailAddress()); + mailsEntity.setToName(entity.getUserName()); + mailsEntity.setTitle(title); + mailsEntity.setContent(contents); + mailsDao.insert(mailsEntity); + } + } + } + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + UsersEntity user = JSON.decode(notificationsEntity.getContent(), UsersEntity.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), notificationsEntity.getTitle()); + + String title = template.getTitle(); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{UserId}", String.valueOf(user.getUserId())); + contents = contents.replace("{UserName}", user.getUserName()); + contents = contents.replace("{UserMail}", user.getMailAddress()); + notificationsEntity.setContent(contents); + } + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/CommentInsertNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/CommentInsertNotification.java new file mode 100644 index 000000000..40e4f4dec --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/CommentInsertNotification.java @@ -0,0 +1,329 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.support.project.aop.Aspect; +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.bat.WebhookBat; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.NotifyType; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.NotifyConfigsDao; +import org.support.project.knowledge.dao.NotifyQueuesDao; +import org.support.project.knowledge.dao.WebhookConfigsDao; +import org.support.project.knowledge.dao.WebhooksDao; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.entity.NotifyConfigsEntity; +import org.support.project.knowledge.entity.NotifyQueuesEntity; +import org.support.project.knowledge.entity.WebhookConfigsEntity; +import org.support.project.knowledge.entity.WebhooksEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.knowledge.logic.NotifyCommentLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.knowledge.logic.WebhookLogic; +import org.support.project.knowledge.vo.notification.CommentInsert; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +/** + * ナレッジにコメントが登録された場合の通知 + * @author koda + */ +@DI(instance = Instance.Prototype) +public class CommentInsertNotification extends AbstractQueueNotification implements DesktopNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(CommentInsertNotification.class); + /** インスタンス取得 */ + public static CommentInsertNotification get() { + return Container.getComp(CommentInsertNotification.class); + } + + /** Added CommentsEntity */ + private CommentsEntity comment; + public CommentsEntity getComment() { + return comment; + } + public void setComment(CommentsEntity comment) { + this.comment = comment; + } + + /** knowledge id what is sended */ + private List sendedCommentKnowledgeIds = new ArrayList<>(); + + @Override + public void insertNotifyQueue() { + NotifyQueuesEntity entity = new NotifyQueuesEntity(); + entity.setHash(RandomUtil.randamGen(30)); + entity.setType(TYPE_KNOWLEDGE_COMMENT); + entity.setId(comment.getCommentNo()); + + NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); + NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(entity.getType(), entity.getId()); + if (exist == null) { + notifyQueuesDao.insert(entity); + } + } + + + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void notify(NotifyQueuesEntity notifyQueue) throws Exception { + CommentsDao commentsDao = CommentsDao.get(); + CommentsEntity comment = commentsDao.selectOnKey(notifyQueue.getId()); + if (null == comment) { + LOG.warn("Comment record not found. id: " + notifyQueue.getId()); + return; + } + + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + KnowledgesEntity knowledge = knowledgesDao.selectOnKey(comment.getKnowledgeId()); + if (null == knowledge) { + LOG.warn("Knowledge record not found. id: " + notifyQueue.getId()); + return; + } + + if (sendedCommentKnowledgeIds.contains(knowledge.getKnowledgeId())) { + if (LOG.isDebugEnabled()) { + LOG.debug("Knowledge [" + knowledge.getKnowledgeId() + "] "); + } + return; + } else { + sendedCommentKnowledgeIds.add(knowledge.getKnowledgeId()); + } + + sendCommentWebhook(comment, knowledge); + + UsersDao usersDao = UsersDao.get(); + UsersEntity commentUser = usersDao.selectOnKey(comment.getInsertUser()); + + // 登録者に通知 + UsersEntity user = NotifyCommentLogic.get().getInsertUserOnComment(NotifyType.Mail, comment, knowledge); + if (user != null) { + // 画面での通知の情報を登録 + NotificationsEntity notification = insertNotificationOnComentInsert(knowledge, comment, commentUser, + MailLogic.NOTIFY_INSERT_COMMENT_MYITEM); + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, user); + + Locale locale = user.getLocale(); + MailLocaleTemplatesEntity template = MailLogic.get().load(locale, MailLogic.NOTIFY_INSERT_COMMENT_MYITEM); + sendCommentMail(comment, knowledge, commentUser, user, template); + } + // 宛先のナレッジにコメント追加で通知が欲しいユーザに通知 + NotificationsEntity notification = insertNotificationOnComentInsert(knowledge, comment, commentUser, + MailLogic.NOTIFY_INSERT_COMMENT); + List users = NotifyCommentLogic.get().getTargetUsersOnComment(NotifyType.Mail, comment, knowledge); + for (UsersEntity target : users) { + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, target); + + // 宛先にメール送信 + Locale locale = target.getLocale(); + MailLocaleTemplatesEntity template = MailLogic.get().load(locale, MailLogic.NOTIFY_INSERT_COMMENT); + sendCommentMail(comment, knowledge, commentUser, target, template); + } + } + + /** + * 画面での通知の情報を登録 + * @param knowledge + * @param comment + * @param commentUser + * @param notifyInsertCommentMyitem + * @return + */ + private NotificationsEntity insertNotificationOnComentInsert(KnowledgesEntity knowledge, CommentsEntity comment, UsersEntity commentUser, + String template) { + // 通知情報を作成 + NotificationsEntity notification = new NotificationsEntity(); + notification.setTitle(template); + + CommentInsert info = new CommentInsert(); + info.setKnowledgeId(knowledge.getKnowledgeId()); + info.setKnowledgeTitle(knowledge.getTitle()); + info.setUpdateUser(knowledge.getUpdateUserName()); + + info.setCommentContents(comment.getComment()); + info.setCommentInsertUser(commentUser.getUserName()); + + notification.setContent(JSON.encode(info)); + notification = NotificationsDao.get().insert(notification); + return notification; + } + + + /** + * コメントが追加されたメールを通知する + * @param comment コメントの情報 + * @param knowledge ナレッジの情報 + * @param commentUser コメントを登録したユーザの情報 + * @param user メールの送信先 + * @throws Exception + */ + private void sendCommentMail(CommentsEntity comment, KnowledgesEntity knowledge, UsersEntity commentUser, + UsersEntity user, MailLocaleTemplatesEntity template) + throws Exception { + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(user.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + user.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(user.getMailAddress()); + mailsEntity.setToName(user.getUserName()); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + contents = contents.replace("{Contents}", MailLogic.get().getMailContent(knowledge.getContent())); + if (commentUser != null) { + contents = contents.replace("{CommentInsertUser}", commentUser.getUserName()); + } else { + contents = contents.replace("{CommentInsertUser}", ""); + } + contents = contents.replace("{CommentContents}", MailLogic.get().getMailContent(comment.getComment())); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + + mailsEntity.setContent(contents); + if (LOG.isDebugEnabled()) { + LOG.debug("News email has been registered. [type] comment added. [knowledge]" + knowledge.getKnowledgeId().toString() + + " [target] " + user.getMailAddress()); + } + MailsDao.get().insert(mailsEntity); + } + + /** + * コメント追加のWebhookの登録を行う + * @param comment + * @param knowledge + */ + private void sendCommentWebhook(CommentsEntity comment, KnowledgesEntity knowledge) { + WebhookConfigsDao webhookConfigsDao = WebhookConfigsDao.get(); + List webhookConfigsEntities = webhookConfigsDao.selectOnHook(WebhookConfigsEntity.HOOK_COMMENTS); + + if (0 == webhookConfigsEntities.size()) { + return; + } + + WebhookLogic webhookLogic = WebhookLogic.get(); + Map commentData = webhookLogic.getCommentData(comment, knowledge); + + WebhooksEntity webhooksEntity = new WebhooksEntity(); + String webhookId = idGen("Notify"); + webhooksEntity.setWebhookId(webhookId); + webhooksEntity.setStatus(WebhookBat.WEBHOOK_STATUS_UNSENT); + webhooksEntity.setHook(WebhookConfigsEntity.HOOK_COMMENTS); + webhooksEntity.setContent(JSON.encode(commentData)); + + WebhooksDao.get().insert(webhooksEntity); + } + + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + CommentInsert update = JSON.decode(notificationsEntity.getContent(), CommentInsert.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), notificationsEntity.getTitle()); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", String.valueOf(update.getKnowledgeId())); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(update.getKnowledgeTitle(), 80)); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", String.valueOf(update.getKnowledgeId())); + contents = contents.replace("{KnowledgeTitle}", update.getKnowledgeTitle()); + contents = contents.replace("{User}", update.getUpdateUser()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(update.getKnowledgeId())); + KnowledgesEntity entity = KnowledgeLogic.get().select(update.getKnowledgeId(), loginedUser); + if (entity != null) { + contents = contents.replace("{Contents}", entity.getContent()); + } else { + contents = contents.replace("{Contents}", ""); + } + contents = contents.replace("{CommentInsertUser}", update.getCommentInsertUser()); + contents = contents.replace("{CommentContents}", update.getCommentContents()); + + notificationsEntity.setContent(contents); + } + } + @Override + public MessageResult getMessage(LoginedUser loginuser, Locale locale) { + NotifyConfigsDao dao = NotifyConfigsDao.get(); + NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); // ログインユーザのデスクトップ通知設定 + if (!NotifyLogic.get().flagCheck(entity.getNotifyDesktop())) { + // デスクトップ通知対象外 + return null; + } + + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + KnowledgesEntity knowledge = knowledgesDao.selectOnKey(comment.getKnowledgeId()); + // 登録者に通知 + UsersEntity user = NotifyCommentLogic.get().getInsertUserOnComment(NotifyType.Desktop, comment, knowledge); + if (user != null) { + if (user.getUserId().intValue() == loginuser.getUserId().intValue()) { + // ログインユーザはナレッジ登録者で、自分の登録したナレッジにコメントがついたら通知を希望 + MessageResult messageResult = new MessageResult(); + messageResult.setMessage(Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.myitem.comment", + StringUtils.abbreviate(knowledge.getTitle(), 80))); + messageResult.setResult(NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク + return messageResult; + } + } + // 宛先のナレッジにコメント追加で通知が欲しいユーザに通知 + List users = NotifyCommentLogic.get().getTargetUsersOnComment(NotifyType.Desktop, comment, knowledge); + for (UsersEntity target : users) { + if (target.getUserId().intValue() == loginuser.getUserId().intValue()) { + // 自分宛てのナレッジにコメントがついたので通知 + MessageResult messageResult = new MessageResult(); + messageResult.setMessage( + Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.to.comment", + StringUtils.abbreviate(knowledge.getTitle(), 80))); + messageResult.setResult(NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク + return messageResult; + } + } + return null; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/CommentLikedNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/CommentLikedNotification.java new file mode 100644 index 000000000..644157ab0 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/CommentLikedNotification.java @@ -0,0 +1,191 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import org.support.project.common.config.INT_FLAG; +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.LikeCommentsDao; +import org.support.project.knowledge.dao.NotifyConfigsDao; +import org.support.project.knowledge.dao.NotifyQueuesDao; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.LikeCommentsEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.entity.NotifyConfigsEntity; +import org.support.project.knowledge.entity.NotifyQueuesEntity; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.knowledge.vo.notification.LikeInsert; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +@DI(instance = Instance.Prototype) +public class CommentLikedNotification extends AbstractQueueNotification implements DesktopNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(CommentLikedNotification.class); + /** インスタンス取得 */ + public static CommentLikedNotification get() { + return Container.getComp(CommentLikedNotification.class); + } + + private LikeCommentsEntity like; + /** + * @return the like + */ + public LikeCommentsEntity getLike() { + return like; + } + /** + * @param like the like to set + */ + public void setLike(LikeCommentsEntity like) { + this.like = like; + } + + /** like id what is sended */ + private List sended = new ArrayList<>(); + + + @Override + public void insertNotifyQueue() { + NotifyQueuesEntity entity = new NotifyQueuesEntity(); + entity.setHash(RandomUtil.randamGen(30)); + entity.setType(TYPE_COMMENT_LIKE); + entity.setId(like.getNo()); + + NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); + NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(entity.getType(), entity.getId()); + if (exist == null) { + notifyQueuesDao.insert(entity); + } + } + @Override + public void notify(NotifyQueuesEntity notifyQueue) throws Exception { + LikeCommentsEntity like = LikeCommentsDao.get().selectOnKey(notifyQueue.getId()); + if (null == like) { + LOG.warn("LikeComment record not found. id: " + notifyQueue.getId()); + return; + } + CommentsEntity comment = CommentsDao.get().selectOnKey(like.getCommentNo()); + if (null == comment) { + LOG.warn("Comment record not found."); + return; + } + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(comment.getKnowledgeId()); + if (null == knowledge) { + LOG.warn("Knowledge record not found."); + return; + } + + if (sended.contains(comment.getCommentNo())) { + // この通知キューでは、コメント対し何件のイイネがあっても1回送るだけになる + if (LOG.isDebugEnabled()) { + LOG.debug("comment [" + comment.getCommentNo() + "] "); + } + return; + } else { + sended.add(comment.getCommentNo()); + } + + // イイネを押したユーザ + UsersEntity likeUser = UsersDao.get().selectOnKey(like.getInsertUser()); + + // 宛先のユーザ(コメントを登録したユーザ) + UsersEntity user = UsersDao.get().selectOnKey(comment.getInsertUser()); + if (user != null) { + NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); + NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(user.getUserId()); + // 登録者でかつイイネが登録した場合に通知が欲しい + if (notifyConfigsEntity != null && INT_FLAG.flagCheck(notifyConfigsEntity.getMyItemLike())) { + // 通知情報生成 + NotificationsEntity notification = new NotificationsEntity(); + notification.setTitle(MailLogic.NOTIFY_INSERT_LIKE_COMMENT_MYITEM); + + LikeInsert info = new LikeInsert(); + info.setKnowledgeId(knowledge.getKnowledgeId()); + info.setKnowledgeTitle(knowledge.getTitle()); + info.setCommentNo(comment.getCommentNo()); + + info.setUpdateUser(user.getUserName()); + info.setLikeInsertUser(like.getUserName()); + + notification.setContent(JSON.encode(info)); + notification = NotificationsDao.get().insert(notification); + + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, user); + + // メール送信 + Locale locale = user.getLocale(); + MailLocaleTemplatesEntity template = MailLogic.get().load(locale, MailLogic.NOTIFY_INSERT_LIKE_MYITEM); + LikeInsertNotification.get().sendLikeMail(knowledge, likeUser, user, template); + } + } + } + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + LikeInsert info = JSON.decode(notificationsEntity.getContent(), LikeInsert.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), MailLogic.NOTIFY_INSERT_LIKE_MYITEM); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", String.valueOf(info.getKnowledgeId())); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(info.getKnowledgeTitle(), 80)); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", String.valueOf(info.getKnowledgeId())); + contents = contents.replace("{KnowledgeTitle}", info.getKnowledgeTitle()); + contents = contents.replace("{User}", info.getUpdateUser()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(info.getKnowledgeId())); + CommentsEntity entity = CommentsDao.get().selectOnKey(info.getCommentNo()); + if (entity != null) { + contents = contents.replace("{Contents}", entity.getComment()); + } else { + contents = contents.replace("{Contents}", ""); + } + contents = contents.replace("{LikeInsertUser}", info.getLikeInsertUser()); + notificationsEntity.setContent(contents); + } + } + @Override + public MessageResult getMessage(LoginedUser loginuser, Locale locale) { + NotifyConfigsDao dao = NotifyConfigsDao.get(); + NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); + if (!NotifyLogic.get().flagCheck(entity.getNotifyDesktop())) { + // デスクトップ通知対象外 + return null; + } + CommentsEntity comment = CommentsDao.get().selectOnKey(like.getCommentNo()); + + if (NotifyLogic.get().flagCheck(entity.getMyItemLike()) && comment.getInsertUser().intValue() == loginuser.getUserId().intValue()) { + // 自分で投稿したナレッジにイイネが押されたので通知 + MessageResult messageResult = new MessageResult(); + messageResult.setMessage(Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.myitem.like", + String.valueOf(comment.getKnowledgeId()))); + messageResult.setResult(NotifyLogic.get().makeURL(comment.getKnowledgeId())); // Knowledgeへのリンク + return messageResult; + } + return null; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/DesktopNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/DesktopNotification.java new file mode 100644 index 000000000..dfafe1cc6 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/DesktopNotification.java @@ -0,0 +1,17 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.Locale; + +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; + +public interface DesktopNotification { + /** + * デスクトップ通知するメッセージを取得 + * + * @param loginuser + * @param locale + * @return + */ + MessageResult getMessage(LoginedUser loginuser, Locale locale); +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/EventNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/EventNotification.java new file mode 100644 index 000000000..99dc0f8e4 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/EventNotification.java @@ -0,0 +1,22 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.Calendar; +import java.util.List; + +import org.support.project.knowledge.entity.EventsEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; + +public interface EventNotification extends Notification { + + /** + * イベントの開催通知 + * @param event + * @param knowledge + * @param values + * @param now + */ + void notify(EventsEntity event, KnowledgesEntity knowledge, List values, + Calendar now); + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByDate.java b/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByDate.java new file mode 100644 index 000000000..5d4dc2c90 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByDate.java @@ -0,0 +1,50 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.Calendar; +import java.util.List; +import java.util.TimeZone; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.entity.EventsEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; + +@DI(instance = Instance.Singleton) +public class EventNotificationByDate extends AbstractEventNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(EventNotificationByDate.class); + /** インスタンス取得 */ + public static EventNotificationByDate get() { + return Container.getComp(EventNotificationByDate.class); + } + + @Override + public void notify(EventsEntity event, KnowledgesEntity knowledge, List values, Calendar now) { + int timing = NOTIFY_STATUS_BEFORE_DATE; + if (event.getNotifyStatus() >= timing) { + // 既に通知済 + return; + } + // 今日? + TimeZone timezone = TimeZone.getTimeZone(event.getTimeZone()); + Calendar today = Calendar.getInstance(timezone); + today.setTimeInMillis(now.getTimeInMillis()); + + Calendar eventDay = Calendar.getInstance(timezone); + eventDay.setTimeInMillis(event.getStartDateTime().getTime()); + if (today.get(Calendar.YEAR) != eventDay.get(Calendar.YEAR) || + today.get(Calendar.MONTH) != eventDay.get(Calendar.MONTH) || + today.get(Calendar.DATE) != eventDay.get(Calendar.DATE)) { + // イベント当日以外は通知しない + return; + } + LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 本日開催"); + sendNotify(event, knowledge, values, timing); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByMinute.java b/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByMinute.java new file mode 100644 index 000000000..b83d16f32 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByMinute.java @@ -0,0 +1,45 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.Calendar; +import java.util.List; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.entity.EventsEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; + +@DI(instance = Instance.Singleton) +public class EventNotificationByMinute extends AbstractEventNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(EventNotificationByMinute.class); + /** インスタンス取得 */ + public static EventNotificationByMinute get() { + return Container.getComp(EventNotificationByMinute.class); + } + + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void notify(EventsEntity event, KnowledgesEntity knowledge, List values, Calendar now) { + int timing = NOTIFY_STATUS_BEFORE_MIN; + if (event.getNotifyStatus() >= timing) { + // 既に通知済 + return; + } + if (LOG.isDebugEnabled()) { + LOG.debug("開始までの時間: " + (event.getStartDateTime().getTime() - now.getTimeInMillis())); + } + // 30分を切った? + if (event.getStartDateTime().getTime() <= now.getTimeInMillis() || + event.getStartDateTime().getTime() - now.getTimeInMillis() > (1000 * 60 * 30)) { + return; + } + LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 30分前"); + sendNotify(event, knowledge, values, timing); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByWeek.java b/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByWeek.java new file mode 100644 index 000000000..38e1104ff --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/EventNotificationByWeek.java @@ -0,0 +1,43 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.Calendar; +import java.util.List; +import java.util.TimeZone; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.entity.EventsEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; + +@DI(instance = Instance.Singleton) +public class EventNotificationByWeek extends AbstractEventNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(EventNotificationByWeek.class); + /** インスタンス取得 */ + public static EventNotificationByWeek get() { + return Container.getComp(EventNotificationByWeek.class); + } + @Override + public void notify(EventsEntity event, KnowledgesEntity knowledge, List values, Calendar now) { + int timing = NOTIFY_STATUS_BEFORE_WEEK; + if (event.getNotifyStatus() >= timing) { + // 既に通知済 + return; + } + //日曜日?(イベントのタイムゾーンで) + TimeZone timezone = TimeZone.getTimeZone(event.getTimeZone()); + Calendar today = Calendar.getInstance(timezone); + today.setTimeInMillis(now.getTimeInMillis()); + if (today.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { + // 日曜日でない場合は通知しない + return; + } + LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 今週開催"); + sendNotify(event, knowledge, values, timing); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/KnowledgeUpdateNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/KnowledgeUpdateNotification.java new file mode 100644 index 000000000..4baf6ac84 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/KnowledgeUpdateNotification.java @@ -0,0 +1,489 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.support.project.aop.Aspect; +import org.support.project.common.config.INT_FLAG; +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.NumberUtils; +import org.support.project.common.util.RandomUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.bat.WebhookBat; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.dao.ExUsersDao; +import org.support.project.knowledge.dao.KnowledgeGroupsDao; +import org.support.project.knowledge.dao.KnowledgeItemValuesDao; +import org.support.project.knowledge.dao.KnowledgeUsersDao; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.NotifyConfigsDao; +import org.support.project.knowledge.dao.NotifyQueuesDao; +import org.support.project.knowledge.dao.TargetsDao; +import org.support.project.knowledge.dao.TemplateMastersDao; +import org.support.project.knowledge.dao.WebhookConfigsDao; +import org.support.project.knowledge.dao.WebhooksDao; +import org.support.project.knowledge.entity.KnowledgeGroupsEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgeUsersEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.entity.NotifyConfigsEntity; +import org.support.project.knowledge.entity.NotifyQueuesEntity; +import org.support.project.knowledge.entity.TemplateItemsEntity; +import org.support.project.knowledge.entity.TemplateMastersEntity; +import org.support.project.knowledge.entity.WebhookConfigsEntity; +import org.support.project.knowledge.entity.WebhooksEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.knowledge.logic.WebhookLogic; +import org.support.project.knowledge.vo.GroupUser; +import org.support.project.knowledge.vo.notification.KnowledgeUpdate; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.entity.GroupsEntity; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +/** + * ナレッジを登録・更新した際の通知処理 + * @author koda + */ +@DI(instance = Instance.Prototype) +public class KnowledgeUpdateNotification extends AbstractQueueNotification implements DesktopNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(KnowledgeUpdateNotification.class); + /** インスタンス取得 */ + public static KnowledgeUpdateNotification get() { + return Container.getComp(KnowledgeUpdateNotification.class); + } + + /** Updated KnowledgesEntity */ + private KnowledgesEntity knowledge; + public KnowledgesEntity getKnowledge() { + return knowledge; + } + public void setKnowledge(KnowledgesEntity knowledge) { + this.knowledge = knowledge; + } + @Override + public void insertNotifyQueue() { + NotifyQueuesEntity entity = new NotifyQueuesEntity(); + entity.setHash(RandomUtil.randamGen(30)); + entity.setType(getType()); + entity.setId(knowledge.getKnowledgeId()); + + NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); + // 重複チェックし + if (NumberUtils.is(entity.getType(), QueueNotification.TYPE_KNOWLEDGE_INSERT)) { + // ナレッジの新規登録は必ず通知のキューに入れる + notifyQueuesDao.insert(entity); + } else if (NumberUtils.is(entity.getType(), QueueNotification.TYPE_KNOWLEDGE_UPDATE)) { + // ナレッジが更新された場合、キューに「登録通知」もしくは「更新通知」が存在しているのであれば登録しない + NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(entity.getType(), entity.getId()); + if (exist == null) { + exist = notifyQueuesDao.selectOnTypeAndId(QueueNotification.TYPE_KNOWLEDGE_INSERT, entity.getId()); + if (exist == null) { + notifyQueuesDao.insert(entity); + } + } + } + } + + + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void notify(NotifyQueuesEntity notifyQueue) throws Exception { + // ナレッジが登録/更新された + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + KnowledgesEntity knowledge = knowledgesDao.selectOnKeyWithUserName(notifyQueue.getId()); + if (null == knowledge) { + LOG.warn("Knowledge record not found. id: " + notifyQueue.getId()); + return; + } + + // Webhook通知 + sendKnowledgeWebhook(knowledge, notifyQueue.getType()); + // 「非公開」のナレッジは、メール通知対象外 + if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PUBLIC) { + notifyPublicKnowledgeUpdate(notifyQueue, knowledge); + updateNotifyStatus(knowledge); + } else if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { + notifyProtectKnowledgeUpdate(notifyQueue, knowledge); + updateNotifyStatus(knowledge); + } + + } + /** + * 「公開」のナレッジを登録・更新した際にメール通知を送信する + * @param notifyQueuesEntity + * @param knowledge + * @throws Exception + */ + private void notifyPublicKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity, KnowledgesEntity knowledge) throws Exception { + //ナレッジ登録ONでかつ、公開区分「公開」を除外しないユーザに通知 + List users = ExUsersDao.get().selectNotifyPublicUsers(); + notifyKnowledgeUpdateToUsers(notifyQueuesEntity, knowledge, users); + } + /** + * 「保護」のナレッジを登録・更新した際にメール通知を送信する + * @param notifyQueuesEntity + * @param knowledge + * @throws Exception + */ + private void notifyProtectKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity, KnowledgesEntity knowledge) throws Exception { + List users = new ArrayList<>(); + // 宛先の一覧取得 + TargetsDao targetsDao = TargetsDao.get(); + List targetUsers = targetsDao.selectUsersOnKnowledgeId(knowledge.getKnowledgeId()); + users.addAll(targetUsers); + + //グループの一覧 + List targetGroups = targetsDao.selectGroupsOnKnowledgeId(knowledge.getKnowledgeId()); + for (GroupsEntity groupsEntity : targetGroups) { + List groupUsers = ExUsersDao.get().selectGroupUser(groupsEntity.getGroupId(), 0, Integer.MAX_VALUE); + for (GroupUser groupUser : groupUsers) { + if (!contains(users, groupUser)) { + users.add(groupUser); + } + } + } + + Iterator iterator = users.iterator(); + while (iterator.hasNext()) { + UsersEntity usersEntity = (UsersEntity) iterator.next(); + // 自分宛てのナレッジ登録/更新で通知するかどうかの判定 + NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); + NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(usersEntity.getUserId()); + if (notifyConfigsEntity == null) { + iterator.remove(); + } else if (!INT_FLAG.flagCheck(notifyConfigsEntity.getToItemSave())) { + iterator.remove(); + } + } + notifyKnowledgeUpdateToUsers(notifyQueuesEntity, knowledge, users); + } + + /** + * 指定のユーザ一覧に、ナレッジを登録・更新した際にメール通知を送信する + * @param notifyQueuesEntity + * @param knowledge + * @param users + * @throws Exception + */ + private void notifyKnowledgeUpdateToUsers(NotifyQueuesEntity notifyQueuesEntity, KnowledgesEntity knowledge, List users) + throws Exception { + StringBuilder content = new StringBuilder(); + // テンプレートの種類をセット + TemplateMastersEntity templateMaster = TemplateMastersDao.get().selectWithItems(knowledge.getTypeId()); + content.append("Type: ").append(templateMaster.getTypeName()).append("\n"); + // テンプレートの拡張項目の情報もメールにセットする + List values = KnowledgeItemValuesDao.get().selectOnKnowledgeId(knowledge.getKnowledgeId()); + List items = templateMaster.getItems(); + for (KnowledgeItemValuesEntity val : values) { + for (TemplateItemsEntity item : items) { + if (val.getItemNo().equals(item.getItemNo())) { + item.setItemValue(val.getItemValue()); + content.append(item.getItemName()).append(": ").append(item.getItemValue()).append("\n"); + break; + } + } + } + if (values.size() > 0) { + content.append("\n"); + } + content.append(knowledge.getContent()); + + // 画面での通知の情報を登録 + NotificationsEntity notification = insertNotificationOnKnowledgeUpdate(knowledge); + + for (UsersEntity usersEntity : users) { + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, usersEntity); + + if (!StringUtils.isEmailAddress(usersEntity.getMailAddress())) { + // 送信先のメールアドレスが不正なのでこのユーザにはメール送信しない + LOG.warn("mail targget [" + usersEntity.getMailAddress() + "] is wrong."); + continue; + } + if (LOG.isTraceEnabled()) { + LOG.trace("[Notify] " + usersEntity.getMailAddress()); + } + Locale locale = usersEntity.getLocale(); + MailLocaleTemplatesEntity template; + if (knowledge.getNotifyStatus() == null || knowledge.getNotifyStatus().intValue() == 0) { + template = MailLogic.get().load(locale, MailLogic.NOTIFY_INSERT_KNOWLEDGE); + } else { + template = MailLogic.get().load(locale, MailLogic.NOTIFY_UPDATE_KNOWLEDGE); + } + // メール送信 + insertNotifyKnowledgeUpdateMailQue(knowledge, usersEntity, template, content.toString()); + } + } + + /** + * メール送信のキュー情報を登録する + * @param knowledge + * @param usersEntity + * @param content + * @param config + * @throws Exception + */ + private void insertNotifyKnowledgeUpdateMailQue(KnowledgesEntity knowledge, UsersEntity usersEntity, + MailLocaleTemplatesEntity template, String content) throws Exception { + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(usersEntity.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + usersEntity.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(usersEntity.getMailAddress()); + mailsEntity.setToName(usersEntity.getUserName()); + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + contents = contents.replace("{User}", knowledge.getUpdateUserName()); + + // コンテンツがHTMLであった場合、テキストを取得する + contents = contents.replace("{Contents}", MailLogic.get().getMailContent(content)); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + mailsEntity.setContent(contents); + if (LOG.isDebugEnabled()) { + LOG.debug("News email has been registered. [type] knowledge update. [knowledge]" + knowledge.getKnowledgeId().toString() + + " [target] " + usersEntity.getMailAddress()); + } + MailsDao.get().insert(mailsEntity); + } + + /** + * 記事の追加・更新のWebhookの登録を行う + * @param comment + * @param knowledge + */ + private void sendKnowledgeWebhook(KnowledgesEntity knowledge, int type) { + WebhookConfigsDao webhookConfigsDao = WebhookConfigsDao.get(); + List webhookConfigsEntities = webhookConfigsDao.selectOnHook(WebhookConfigsEntity.HOOK_KNOWLEDGES); + + if (0 == webhookConfigsEntities.size()) { + return; + } + + WebhookLogic webhookLogic = WebhookLogic.get(); + Map knowledgeData = webhookLogic.getKnowledgeData(knowledge, type); + + WebhooksEntity webhooksEntity = new WebhooksEntity(); + String webhookId = idGen("Notify"); + webhooksEntity.setWebhookId(webhookId); + webhooksEntity.setStatus(WebhookBat.WEBHOOK_STATUS_UNSENT); + webhooksEntity.setHook(WebhookConfigsEntity.HOOK_KNOWLEDGES); + webhooksEntity.setContent(JSON.encode(knowledgeData)); + + WebhooksDao.get().insert(webhooksEntity); + } + + /** + * 既に指定のユーザが追加されているのか確認 + * @param users + * @param groupUser + * @return + */ + private boolean contains(List users, UsersEntity groupUser) { + for (UsersEntity usersEntity : users) { + if (usersEntity.equalsOnKey(groupUser)) { + return true; + } + } + return false; + } + + /** + * 通知を送ったもののステータスを更新 + * @param knowledge + */ + private void updateNotifyStatus(KnowledgesEntity knowledge) { + if (knowledge.getNotifyStatus() == null || knowledge.getNotifyStatus().intValue() == 0) { + knowledge.setNotifyStatus(INT_FLAG.ON.getValue()); // 通知済へ + KnowledgesDao.get().physicalUpdate(knowledge); // 更新日時などは更新しない + } + } + + + /** + * Knowledgeの登録/更新時の通知情報を作成 + * @param knowledge + * @return + */ + private NotificationsEntity insertNotificationOnKnowledgeUpdate(KnowledgesEntity knowledge) { + // 通知情報を作成 + NotificationsEntity notification = new NotificationsEntity(); + if (knowledge.getNotifyStatus() == null || knowledge.getNotifyStatus().intValue() == 0) { + notification.setTitle(MailLogic.NOTIFY_INSERT_KNOWLEDGE); + } else { + notification.setTitle(MailLogic.NOTIFY_UPDATE_KNOWLEDGE); + } + KnowledgeUpdate update = new KnowledgeUpdate(); + update.setKnowledgeId(knowledge.getKnowledgeId()); + update.setKnowledgeTitle(knowledge.getTitle()); + update.setUpdateUser(knowledge.getUpdateUserName()); + notification.setContent(JSON.encode(update)); + notification = NotificationsDao.get().insert(notification); + return notification; + } + + /** + * ユーザへの通知を意味のある形へ変換 + * @param notificationsEntity + * @param loginedUser + */ + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + String category = notificationsEntity.getTitle(); + if (MailLogic.NOTIFY_INSERT_KNOWLEDGE.equals(category) || MailLogic.NOTIFY_UPDATE_KNOWLEDGE.equals(category)) { + KnowledgeUpdate update = JSON.decode(notificationsEntity.getContent(), KnowledgeUpdate.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), MailLogic.NOTIFY_INSERT_KNOWLEDGE); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", String.valueOf(update.getKnowledgeId())); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(update.getKnowledgeTitle(), 80)); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", String.valueOf(update.getKnowledgeId())); + contents = contents.replace("{KnowledgeTitle}", update.getKnowledgeTitle()); + contents = contents.replace("{User}", update.getUpdateUser()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(update.getKnowledgeId())); + KnowledgesEntity entity = KnowledgeLogic.get().select(update.getKnowledgeId(), loginedUser); + if (entity != null) { + contents = contents.replace("{Contents}", entity.getContent()); + } else { + contents = contents.replace("{Contents}", ""); + } + notificationsEntity.setContent(contents); + } + } + } + @Override + public MessageResult getMessage(LoginedUser loginuser, Locale locale) { + if (getType() == TYPE_KNOWLEDGE_UPDATE) { + return getUpdateKnowledgeMessage(loginuser, locale, "knowledge.notify.msg.desktop.to.update"); + } else { + return getUpdateKnowledgeMessage(loginuser, locale, "knowledge.notify.msg.desktop.to.insert"); + } + } + + /** + * 指定のナレッジは、自分宛てのナレッジかどうかを判定し、メッセージを取得する + * + * @param loginuser + * @param knowledge + * @return + */ + private MessageResult getUpdateKnowledgeMessage(LoginedUser loginuser, Locale locale, String title) { + // TODO ストック機能ができたら、ストックしたナレッジの更新かどうかを判定する + if (isToKnowledgeSave(loginuser, knowledge)) { + MessageResult messageResult = new MessageResult(); + messageResult.setMessage( + Resources.getInstance(locale).getResource(title, String.valueOf(knowledge.getKnowledgeId()))); + messageResult.setResult(NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク + return messageResult; + } + return null; + } + + + /** + * 自分宛てのナレッジが登録/更新されたか判定する + * + * @param loginuser + * @param knowledge + * @return + */ + private boolean isToKnowledgeSave(LoginedUser loginuser, KnowledgesEntity knowledge) { + NotifyConfigsDao dao = NotifyConfigsDao.get(); + NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); + if (!NotifyLogic.get().flagCheck(entity.getNotifyDesktop())) { + // デスクトップ通知対象外 + return false; + } +// 自分が登録した場合は、通知する必要無し?いったんは通知する +// if (knowledge.getInsertUser().intValue() == loginuser.getUserId().intValue()) { +// return false; +// } + if (!NotifyLogic.get().flagCheck(entity.getToItemSave())) { + // 自分宛てのナレッジが登録/更新されたら通知するがOFF + return false; + } + return isToKnowledge(loginuser, knowledge, entity); + } + + /** + * 指定のナレッジは、自分宛てのナレッジかどうかを判定する 自分宛ては以下の場合を言う ・公開区分が「公開」でかつ、「公開」でも通知する設定になっている場合 ・公開区分が「保護」でかつ、宛先に自分が入っている場合 + * + * @param loginuser + * @param knowledge + * @param entity + * @return + */ + private boolean isToKnowledge(LoginedUser loginuser, KnowledgesEntity knowledge, NotifyConfigsEntity entity) { + if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PUBLIC) { + // 公開のナレッジ + if (!NotifyLogic.get().flagCheck(entity.getToItemIgnorePublic())) { + // 公開も除外しない + return true; + } + } else if (knowledge.getPublicFlag() == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { + // 保護のナレッジ + KnowledgeGroupsDao knowledgeGroupsDao = KnowledgeGroupsDao.get(); + List groupsEntities = knowledgeGroupsDao.selectOnKnowledgeId(knowledge.getKnowledgeId()); + List groups = loginuser.getGroups(); + for (KnowledgeGroupsEntity knowledgeGroupsEntity : groupsEntities) { + for (GroupsEntity groupsEntity : groups) { + if (knowledgeGroupsEntity.getGroupId().intValue() == groupsEntity.getGroupId().intValue()) { + return true; + } + } + } + + KnowledgeUsersDao knowledgeUsersDao = KnowledgeUsersDao.get(); + List usersEntities = knowledgeUsersDao.selectOnKnowledgeId(knowledge.getKnowledgeId()); + for (KnowledgeUsersEntity knowledgeUsersEntity : usersEntities) { + if (knowledgeUsersEntity.getUserId().intValue() == loginuser.getUserId().intValue()) { + return true; + } + } + } + return false; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/LikeInsertNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/LikeInsertNotification.java new file mode 100644 index 000000000..ded6eb270 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/LikeInsertNotification.java @@ -0,0 +1,263 @@ +package org.support.project.knowledge.logic.notification; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import org.support.project.aop.Aspect; +import org.support.project.common.config.INT_FLAG; +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.dao.LikesDao; +import org.support.project.knowledge.dao.NotifyConfigsDao; +import org.support.project.knowledge.dao.NotifyQueuesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.LikesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.entity.NotifyConfigsEntity; +import org.support.project.knowledge.entity.NotifyQueuesEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotificationLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.knowledge.vo.notification.LikeInsert; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.NotificationsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.NotificationsEntity; +import org.support.project.web.entity.UsersEntity; + +import net.arnx.jsonic.JSON; + +/** + * イイネが押されたことを通知 + * @author koda + */ +@DI(instance = Instance.Prototype) +public class LikeInsertNotification extends AbstractQueueNotification implements DesktopNotification { + /** ログ */ + private static final Log LOG = LogFactory.getLog(LikeInsertNotification.class); + /** インスタンス取得 */ + public static LikeInsertNotification get() { + return Container.getComp(LikeInsertNotification.class); + } + + /** like id what is sended */ + private List sendedLikeKnowledgeIds = new ArrayList<>(); + + /** Added LikesEntity */ + private LikesEntity like; + public LikesEntity getLike() { + return like; + } + public void setLike(LikesEntity like) { + this.like = like; + } + + @Override + public void insertNotifyQueue() { + NotifyQueuesEntity entity = new NotifyQueuesEntity(); + entity.setHash(RandomUtil.randamGen(30)); + entity.setType(TYPE_KNOWLEDGE_LIKE); + entity.setId(like.getNo()); + + NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); + NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(entity.getType(), entity.getId()); + if (exist == null) { + notifyQueuesDao.insert(entity); + } + } + + @Override + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void notify(NotifyQueuesEntity notifyQueue) throws Exception { + LikesDao likesDao = LikesDao.get(); + LikesEntity like = likesDao.selectOnKey(notifyQueue.getId()); + if (null == like) { + LOG.warn("Like record not found. id: " + notifyQueue.getId()); + return; + } + + // 同一ユーザでは、イイネの通知は1回きりにする + + + + + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + KnowledgesEntity knowledge = knowledgesDao.selectOnKey(like.getKnowledgeId()); + if (null == knowledge) { + LOG.warn("Knowledge record not found. id: " + notifyQueue.getId()); + return; + } + + if (sendedLikeKnowledgeIds.contains(knowledge.getKnowledgeId())) { + if (LOG.isDebugEnabled()) { + LOG.debug("Knowledge [" + knowledge.getKnowledgeId() + "] "); + } + return; + } else { + sendedLikeKnowledgeIds.add(knowledge.getKnowledgeId()); + } + + UsersDao usersDao = UsersDao.get(); + UsersEntity likeUser = usersDao.selectOnKey(like.getInsertUser()); + + // 登録者に通知 + UsersEntity user = usersDao.selectOnKey(knowledge.getInsertUser()); + if (user != null) { + NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); + NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(user.getUserId()); + // 登録者でかつイイネが登録した場合に通知が欲しい + if (notifyConfigsEntity != null && INT_FLAG.flagCheck(notifyConfigsEntity.getMyItemLike())) { + // 通知情報生成 + NotificationsEntity notification = insertNotificationOnLikeMyItem(knowledge, like, likeUser); + // 通知とユーザの紐付け + NotificationLogic.get().insertUserNotification(notification, user); + + // メール送信 + Locale locale = user.getLocale(); + MailLocaleTemplatesEntity template = MailLogic.get().load(locale, MailLogic.NOTIFY_INSERT_LIKE_MYITEM); + sendLikeMail(knowledge, likeUser, user, template); + } + } + } + + private NotificationsEntity insertNotificationOnLikeMyItem(KnowledgesEntity knowledge, LikesEntity like, UsersEntity likeUser) { + // 通知情報を作成 + NotificationsEntity notification = new NotificationsEntity(); + notification.setTitle(MailLogic.NOTIFY_INSERT_LIKE_MYITEM); + + LikeInsert info = new LikeInsert(); + info.setKnowledgeId(knowledge.getKnowledgeId()); + info.setKnowledgeTitle(knowledge.getTitle()); + info.setUpdateUser(knowledge.getUpdateUserName()); + if (likeUser != null) { + info.setLikeInsertUser(likeUser.getUserName()); + } else { + info.setLikeInsertUser("anonymous"); + } + + notification.setContent(JSON.encode(info)); + notification = NotificationsDao.get().insert(notification); + return notification; + + } + + /** + * イイネが押されたメールを送る + * @param like + * @param knowledge + * @param likeUser + * @param user + * @param template + * @throws Exception + */ + public void sendLikeMail(KnowledgesEntity knowledge, UsersEntity likeUser, UsersEntity user, + MailLocaleTemplatesEntity template) throws Exception { + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(user.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + user.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(user.getMailAddress()); + mailsEntity.setToName(user.getUserName()); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + contents = contents.replace("{Contents}", MailLogic.get().getMailContent(knowledge.getContent())); + if (likeUser != null) { + contents = contents.replace("{LikeInsertUser}", likeUser.getUserName()); + } else { + contents = contents.replace("{LikeInsertUser}", ""); + } + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + + mailsEntity.setContent(contents); + if (LOG.isDebugEnabled()) { + LOG.debug("News email has been registered. [type] Like added. [knowledge]" + knowledge.getKnowledgeId().toString() + + " [target] " + user.getMailAddress()); + } + MailsDao.get().insert(mailsEntity); + } + + + @Override + public void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target) { + LikeInsert info = JSON.decode(notificationsEntity.getContent(), LikeInsert.class); + MailLocaleTemplatesEntity template = MailLogic.get().load(loginedUser.getLocale(), notificationsEntity.getTitle()); + + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", String.valueOf(info.getKnowledgeId())); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(info.getKnowledgeTitle(), 80)); + notificationsEntity.setTitle(title); + + if (target == TARGET.detail) { + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", String.valueOf(info.getKnowledgeId())); + contents = contents.replace("{KnowledgeTitle}", info.getKnowledgeTitle()); + contents = contents.replace("{User}", info.getUpdateUser()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(info.getKnowledgeId())); + KnowledgesEntity entity = KnowledgeLogic.get().select(info.getKnowledgeId(), loginedUser); + if (entity != null) { + contents = contents.replace("{Contents}", entity.getContent()); + } else { + contents = contents.replace("{Contents}", ""); + } + contents = contents.replace("{LikeInsertUser}", info.getLikeInsertUser()); + notificationsEntity.setContent(contents); + } + } + @Override + public MessageResult getMessage(LoginedUser loginuser, Locale locale) { + NotifyConfigsDao dao = NotifyConfigsDao.get(); + NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); + if (!NotifyLogic.get().flagCheck(entity.getNotifyDesktop())) { + // デスクトップ通知対象外 + return null; + } + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + KnowledgesEntity knowledge = knowledgesDao.selectOnKey(like.getKnowledgeId()); + + if (NotifyLogic.get().flagCheck(entity.getMyItemLike()) && knowledge.getInsertUser().intValue() == loginuser.getUserId().intValue()) { + // 自分で投稿したナレッジにイイネが押されたので通知 + MessageResult messageResult = new MessageResult(); + messageResult.setMessage(Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.myitem.like", + String.valueOf(knowledge.getKnowledgeId()))); + messageResult.setResult(NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク + return messageResult; + } + + return null; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/Notification.java b/src/main/java/org/support/project/knowledge/logic/notification/Notification.java new file mode 100644 index 000000000..2c1990ad8 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/Notification.java @@ -0,0 +1,18 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.entity.NotificationsEntity; + +public interface Notification { + enum TARGET { + list, detail + } + + /** + * 画面での通知情報を、表示する形式に変換する + * @param notificationsEntity + * @param loginedUser + * @param target + */ + void convNotification(NotificationsEntity notificationsEntity, LoginedUser loginedUser, TARGET target); +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/ParticipateChangeStatusForParticipantNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateChangeStatusForParticipantNotification.java new file mode 100644 index 000000000..4102f0bcf --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateChangeStatusForParticipantNotification.java @@ -0,0 +1,91 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.UsersEntity; + +/** + * キャンセル待ちのユーザに、キャンセルがあったため参加になったことを通知 + * @author koda + */ +@DI(instance = Instance.Singleton) +public class ParticipateChangeStatusForParticipantNotification extends AbstractParticipateNotification{ + /** ログ */ + private static final Log LOG = LogFactory.getLog(ParticipateChangeStatusForParticipantNotification.class); + /** インスタンス取得 */ + public static ParticipateChangeStatusForParticipantNotification get() { + return Container.getComp(ParticipateChangeStatusForParticipantNotification.class); + } + @Override + public void notify(Long knowledgeId, Integer userId, Integer status) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); + if (knowledge == null) { + LOG.info("knowledge [" + knowledgeId + "] is not exists."); + return; + } + // 参加者 + UsersEntity participant = UsersDao.get().selectOnKey(userId); + if (participant == null) { + LOG.warn("sponsor or participant is not exist."); + return; + } + + // 通知情報生成 + insertNotification(knowledge, userId, status, MailLogic.NOTIFY_CHANGE_EVENT_STATUS); + + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(participant.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + participant.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(participant.getMailAddress()); + mailsEntity.setToName(participant.getUserName()); + + MailLocaleTemplatesEntity template = MailLogic.get().load(participant.getLocale(), MailLogic.NOTIFY_CHANGE_EVENT_STATUS); + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + StringBuilder builder = new StringBuilder(); + Resources resources = Resources.getInstance(participant.getLocale()); + builder.append(resources.getResource("knowledge.view.label.status.participation")); + contents = contents.replace("{Status}", builder.toString()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + + mailsEntity.setContent(contents); + MailsDao.get().insert(mailsEntity); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/ParticipateForParticipantNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateForParticipantNotification.java new file mode 100644 index 000000000..95c1ebe1a --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateForParticipantNotification.java @@ -0,0 +1,96 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.EventsLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.UsersEntity; + +/** + * 参加登録したことを、参加者へ通知 + * @author koda + */ +@DI(instance = Instance.Singleton) +public class ParticipateForParticipantNotification extends AbstractParticipateNotification{ + /** ログ */ + private static final Log LOG = LogFactory.getLog(ParticipateForParticipantNotification.class); + /** インスタンス取得 */ + public static ParticipateForParticipantNotification get() { + return Container.getComp(ParticipateForParticipantNotification.class); + } + + @Override + public void notify(Long knowledgeId, Integer userId, Integer status) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); + if (knowledge == null) { + LOG.info("knowledge [" + knowledgeId + "] is not exists."); + return; + } + // 参加者 + UsersEntity participant = UsersDao.get().selectOnKey(userId); + if (participant == null) { + LOG.warn("sponsor or participant is not exist."); + return; + } + + // 通知情報生成 + insertNotification(knowledge, userId, status, MailLogic.NOTIFY_REGISTRATION_EVENT); + + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(participant.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + participant.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(participant.getMailAddress()); + mailsEntity.setToName(participant.getUserName()); + + MailLocaleTemplatesEntity template = MailLogic.get().load(participant.getLocale(), MailLogic.NOTIFY_REGISTRATION_EVENT); + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + StringBuilder builder = new StringBuilder(); + Resources resources = Resources.getInstance(participant.getLocale()); + if (status == EventsLogic.STATUS_PARTICIPATION) { + builder.append(resources.getResource("knowledge.view.label.status.participation")); + } else { + builder.append(resources.getResource("knowledge.view.label.status.wait.cansel")); + } + contents = contents.replace("{Status}", builder.toString()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + + mailsEntity.setContent(contents); + MailsDao.get().insert(mailsEntity); + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/ParticipateForSponsorNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateForSponsorNotification.java new file mode 100644 index 000000000..0a34951a6 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateForSponsorNotification.java @@ -0,0 +1,100 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.common.config.Resources; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.EventsLogic; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.UsersEntity; + +/** + * 参加登録があったことを、開催者へ通知 + * @author koda + */ +@DI(instance = Instance.Singleton) +public class ParticipateForSponsorNotification extends AbstractParticipateNotification{ + /** ログ */ + private static final Log LOG = LogFactory.getLog(ParticipateForSponsorNotification.class); + /** インスタンス取得 */ + public static ParticipateForSponsorNotification get() { + return Container.getComp(ParticipateForSponsorNotification.class); + } + + @Override + public void notify(Long knowledgeId, Integer userId, Integer status) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); + if (knowledge == null) { + LOG.info("knowledge [" + knowledgeId + "] is not exists."); + return; + } + // 開催者 + UsersEntity sponsor = UsersDao.get().selectOnKey(knowledge.getInsertUser()); + // 参加者 + UsersEntity participant = UsersDao.get().selectOnKey(userId); + if (sponsor == null || participant == null) { + LOG.warn("sponsor or participant is not exist."); + return; + } + + // 通知情報生成 + insertNotification(knowledge, userId, status, MailLogic.NOTIFY_ADD_PARTICIPATE); + + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(sponsor.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + sponsor.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(sponsor.getMailAddress()); + mailsEntity.setToName(sponsor.getUserName()); + + MailLocaleTemplatesEntity template = MailLogic.get().load(sponsor.getLocale(), MailLogic.NOTIFY_ADD_PARTICIPATE); + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + StringBuilder builder = new StringBuilder(); + Resources resources = Resources.getInstance(sponsor.getLocale()); + builder.append(participant.getUserName()); + if (status == EventsLogic.STATUS_PARTICIPATION) { + builder.append("[").append(resources.getResource("knowledge.view.label.status.participation")).append("]"); + } else { + builder.append("[").append(resources.getResource("knowledge.view.label.status.wait.cansel")).append("]"); + } + contents = contents.replace("{Participant}", builder.toString()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + + mailsEntity.setContent(contents); + MailsDao.get().insert(mailsEntity); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/ParticipateNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateNotification.java new file mode 100644 index 000000000..2b4996a3e --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateNotification.java @@ -0,0 +1,12 @@ +package org.support.project.knowledge.logic.notification; + +public interface ParticipateNotification extends Notification { + + /** + * 参加登録通知 + * @param knowledgeId + * @param userId + * @param status + */ + void notify(Long knowledgeId, Integer userId, Integer status); +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/ParticipateRemoveForSponsorNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateRemoveForSponsorNotification.java new file mode 100644 index 000000000..6f5ca35d9 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/ParticipateRemoveForSponsorNotification.java @@ -0,0 +1,90 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.MailLocaleTemplatesEntity; +import org.support.project.knowledge.logic.MailLogic; +import org.support.project.knowledge.logic.NotifyLogic; +import org.support.project.web.dao.MailConfigsDao; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.MailConfigsEntity; +import org.support.project.web.entity.MailsEntity; +import org.support.project.web.entity.UsersEntity; + +/** + * 開催者(=登録者)へ参加キャンセルのメール通知 + * @author koda + */ +@DI(instance = Instance.Singleton) +public class ParticipateRemoveForSponsorNotification extends AbstractParticipateNotification{ + /** ログ */ + private static final Log LOG = LogFactory.getLog(ParticipateRemoveForSponsorNotification.class); + /** インスタンス取得 */ + public static ParticipateRemoveForSponsorNotification get() { + return Container.getComp(ParticipateRemoveForSponsorNotification.class); + } + + @Override + public void notify(Long knowledgeId, Integer userId, Integer status) { + KnowledgesEntity knowledge = KnowledgesDao.get().selectOnKey(knowledgeId); + if (knowledge == null) { + LOG.info("knowledge [" + knowledgeId + "] is not exists."); + return; + } + // 開催者 + UsersEntity sponsor = UsersDao.get().selectOnKey(knowledge.getInsertUser()); + // 参加者 + UsersEntity participant = UsersDao.get().selectOnKey(userId); + if (sponsor == null || participant == null) { + LOG.warn("sponsor or participant is not exist."); + return; + } + + // 通知情報生成 + insertNotification(knowledge, userId, status, MailLogic.NOTIFY_REMOVE_PARTICIPATE); + + MailConfigsDao mailConfigsDao = MailConfigsDao.get(); + MailConfigsEntity mailConfigsEntity = mailConfigsDao.selectOnKey(AppConfig.get().getSystemName()); + if (mailConfigsEntity == null) { + // メールの設定が登録されていなければ、送信処理は終了 + LOG.info("mail config is not exists."); + return; + } + if (!StringUtils.isEmailAddress(sponsor.getMailAddress())) { + // 送信先のメールアドレスが不正なので、送信処理は終了 + LOG.warn("mail targget [" + sponsor.getMailAddress() + "] is wrong."); + return; + } + + MailsEntity mailsEntity = new MailsEntity(); + String mailId = idGen("Notify"); + mailsEntity.setMailId(mailId); + mailsEntity.setStatus(MailLogic.MAIL_STATUS_UNSENT); + mailsEntity.setToAddress(sponsor.getMailAddress()); + mailsEntity.setToName(sponsor.getUserName()); + + MailLocaleTemplatesEntity template = MailLogic.get().load(sponsor.getLocale(), MailLogic.NOTIFY_REMOVE_PARTICIPATE); + String title = template.getTitle(); + title = title.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + title = title.replace("{KnowledgeTitle}", StringUtils.abbreviate(knowledge.getTitle(), 80)); + mailsEntity.setTitle(title); + String contents = template.getContent(); + contents = contents.replace("{KnowledgeId}", knowledge.getKnowledgeId().toString()); + contents = contents.replace("{KnowledgeTitle}", knowledge.getTitle()); + contents = contents.replace("{Participant}", participant.getUserName()); + contents = contents.replace("{URL}", NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); + + mailsEntity.setContent(contents); + MailsDao.get().insert(mailsEntity); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/notification/QueueNotification.java b/src/main/java/org/support/project/knowledge/logic/notification/QueueNotification.java new file mode 100644 index 000000000..c4e618073 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/notification/QueueNotification.java @@ -0,0 +1,29 @@ +package org.support.project.knowledge.logic.notification; + +import org.support.project.knowledge.entity.NotifyQueuesEntity; + +public interface QueueNotification extends Notification { + /** notify type: insert knowledge */ + int TYPE_KNOWLEDGE_INSERT = 1; + /** notify type: update knowledge */ + int TYPE_KNOWLEDGE_UPDATE = 2; + /** notify type: add comment */ + int TYPE_KNOWLEDGE_COMMENT = 11; + /** notify type: add like */ + int TYPE_KNOWLEDGE_LIKE = 21; + /** notify type: add like */ + int TYPE_COMMENT_LIKE = 22; + + /** + * メール通知のキューを保存 + * + * @return + */ + void insertNotifyQueue(); + /** + * 通知キューに入っている、通知を処理する + * @param notifyQueue + */ + void notify(NotifyQueuesEntity notifyQueue) throws Exception; + +} diff --git a/src/main/java/org/support/project/knowledge/vo/ActivityHistory.java b/src/main/java/org/support/project/knowledge/vo/ActivityHistory.java new file mode 100644 index 000000000..18d27cb10 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/ActivityHistory.java @@ -0,0 +1,46 @@ +package org.support.project.knowledge.vo; + +import java.util.Date; + +public class ActivityHistory { + private Date date; + private String dispDate; + private String msg; + /** + * @return the date + */ + public Date getDate() { + return date; + } + /** + * @param date the date to set + */ + public void setDate(Date date) { + this.date = date; + } + /** + * @return the dispDate + */ + public String getDispDate() { + return dispDate; + } + /** + * @param dispDate the dispDate to set + */ + public void setDispDate(String dispDate) { + this.dispDate = dispDate; + } + /** + * @return the msg + */ + public String getMsg() { + return msg; + } + /** + * @param msg the msg to set + */ + public void setMsg(String msg) { + this.msg = msg; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/ContributionPointHistory.java b/src/main/java/org/support/project/knowledge/vo/ContributionPointHistory.java new file mode 100644 index 000000000..0c0f51bd7 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/ContributionPointHistory.java @@ -0,0 +1,48 @@ +package org.support.project.knowledge.vo; + +/** + * ContributionPoint の獲得履歴を日付毎に保持するクラス + * @author koda + */ +public class ContributionPointHistory { + private String ymd; + private int total; + private int before; + /** + * @return the ymd + */ + public String getYmd() { + return ymd; + } + /** + * @param ymd the ymd to set + */ + public void setYmd(String ymd) { + this.ymd = ymd; + } + /** + * @return the total + */ + public int getTotal() { + return total; + } + /** + * @param total the total to set + */ + public void setTotal(int total) { + this.total = total; + } + /** + * @return the before + */ + public int getBefore() { + return before; + } + /** + * @param before the before to set + */ + public void setBefore(int before) { + this.before = before; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java b/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java index 8fbc20ba4..b7f5b31c9 100644 --- a/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java +++ b/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java @@ -19,7 +19,10 @@ public class KnowledgeData { private List fileNos; private TemplateMastersEntity template; private Long draftId; - private boolean updateContent; + + private boolean updateContent = false; + private boolean notifyUpdate = false; + private boolean donotUpdateTimeline = false; private String viewersStr; private String editorsStr; @@ -246,6 +249,26 @@ public boolean isUpdateContent() { public void setUpdateContent(boolean updateContent) { this.updateContent = updateContent; } + + + public boolean isNotifyUpdate() { + return notifyUpdate; + } + + + public void setNotifyUpdate(boolean notifyUpdate) { + this.notifyUpdate = notifyUpdate; + } + + + public boolean isDonotUpdateTimeline() { + return donotUpdateTimeline; + } + + + public void setDonotUpdateTimeline(boolean donotUpdateTimeline) { + this.donotUpdateTimeline = donotUpdateTimeline; + } diff --git a/src/main/java/org/support/project/knowledge/vo/Notify.java b/src/main/java/org/support/project/knowledge/vo/Notify.java deleted file mode 100644 index ff40e4d09..000000000 --- a/src/main/java/org/support/project/knowledge/vo/Notify.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.support.project.knowledge.vo; - -import java.util.List; -import java.util.Locale; - -import org.support.project.common.config.Resources; -import org.support.project.common.util.RandomUtil; -import org.support.project.common.util.StringUtils; -import org.support.project.knowledge.config.NotifyType; -import org.support.project.knowledge.dao.KnowledgesDao; -import org.support.project.knowledge.dao.NotifyConfigsDao; -import org.support.project.knowledge.entity.CommentsEntity; -import org.support.project.knowledge.entity.KnowledgesEntity; -import org.support.project.knowledge.entity.LikesEntity; -import org.support.project.knowledge.entity.NotifyConfigsEntity; -import org.support.project.knowledge.entity.NotifyQueuesEntity; -import org.support.project.knowledge.logic.NotifyCommentLogic; -import org.support.project.knowledge.logic.NotifyLogic; -import org.support.project.web.bean.LoginedUser; -import org.support.project.web.bean.MessageResult; -import org.support.project.web.entity.UsersEntity; - -/** - * Class for notify - * @author Koda - */ -public class Notify { - /** notify type: insert knowledge */ - public static final int TYPE_KNOWLEDGE_INSERT = 1; - /** notify type: update knowledge */ - public static final int TYPE_KNOWLEDGE_UPDATE = 2; - /** notify type: add comment */ - public static final int TYPE_KNOWLEDGE_COMMENT = 11; - /** notify type: add like */ - public static final int TYPE_KNOWLEDGE_LIKE = 21; - - /** notify type */ - private int type; - - /** Updated KnowledgesEntity */ - private KnowledgesEntity knowledge; - /** Added CommentsEntity */ - private CommentsEntity comment; - /** Added LikesEntity */ - private LikesEntity like; - - /** - * Knowledge inserted. - * @param entity - */ - public void inserted(KnowledgesEntity entity) { - type = TYPE_KNOWLEDGE_INSERT; - knowledge = entity; - } - /** - * Knowledge updated. - * @param entity - */ - public void updated(KnowledgesEntity entity) { - type = TYPE_KNOWLEDGE_UPDATE; - knowledge = entity; - } - /** - * Comment added. - * @param commentsEntity - */ - public void commented(CommentsEntity commentsEntity) { - type = TYPE_KNOWLEDGE_COMMENT; - comment = commentsEntity; - } - /** - * Like added. - * @param entity - */ - public void liked(LikesEntity entity) { - type = TYPE_KNOWLEDGE_LIKE; - like = entity; - } - /** - * メール通知のキューを取得 - * - * @return - */ - public NotifyQueuesEntity getQueue() { - NotifyQueuesEntity entity = new NotifyQueuesEntity(); - entity.setHash(RandomUtil.randamGen(30)); - entity.setType(type); - - if (type == TYPE_KNOWLEDGE_INSERT || type == TYPE_KNOWLEDGE_UPDATE) { - entity.setId(knowledge.getKnowledgeId()); - } else if (type == TYPE_KNOWLEDGE_COMMENT) { - entity.setId(comment.getCommentNo()); - } else if (type == TYPE_KNOWLEDGE_LIKE) { - entity.setId(like.getNo()); - } - return entity; - } - - /** - * デスクトップ通知するメッセージを取得 - * - * @param loginuser - * @param locale - * @return - */ - public MessageResult getMessage(LoginedUser loginuser, Locale locale) { - if (type == TYPE_KNOWLEDGE_INSERT) { - return NotifyLogic.get().getInsertKnowledgeMessage(loginuser, locale, knowledge); - } else if (type == TYPE_KNOWLEDGE_UPDATE) { - return NotifyLogic.get().getUpdateKnowledgeMessage(loginuser, locale, knowledge); - } else if (type == TYPE_KNOWLEDGE_COMMENT) { - return this.getSaveCommentMessage(loginuser, locale, comment); - } else if (type == TYPE_KNOWLEDGE_LIKE) { - return NotifyLogic.get().getSaveLikeMessage(loginuser, locale, like); - } - return null; - } - /** - * コメント更新時のデスクトップメッセージを取得 - * @param loginuser - * @param locale - * @param comment - * @return - */ - private MessageResult getSaveCommentMessage(LoginedUser loginuser, Locale locale, CommentsEntity comment) { - NotifyConfigsDao dao = NotifyConfigsDao.get(); - NotifyConfigsEntity entity = dao.selectOnKey(loginuser.getUserId()); // ログインユーザのデスクトップ通知設定 - if (!NotifyLogic.get().flagCheck(entity.getNotifyDesktop())) { - // デスクトップ通知対象外 - return null; - } - - KnowledgesDao knowledgesDao = KnowledgesDao.get(); - KnowledgesEntity knowledge = knowledgesDao.selectOnKey(comment.getKnowledgeId()); - // 登録者に通知 - UsersEntity user = NotifyCommentLogic.get().getInsertUserOnComment(NotifyType.Desktop, comment, knowledge); - if (user != null) { - if (user.getUserId().intValue() == loginuser.getUserId().intValue()) { - // ログインユーザはナレッジ登録者で、自分の登録したナレッジにコメントがついたら通知を希望 - MessageResult messageResult = new MessageResult(); - messageResult.setMessage(Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.myitem.comment", - StringUtils.abbreviate(knowledge.getTitle(), 80))); - messageResult.setResult(NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク - return messageResult; - } - } - // 宛先のナレッジにコメント追加で通知が欲しいユーザに通知 - List users = NotifyCommentLogic.get().getTargetUsersOnComment(NotifyType.Desktop, comment, knowledge); - for (UsersEntity target : users) { - if (target.getUserId().intValue() == loginuser.getUserId().intValue()) { - // 自分宛てのナレッジにコメントがついたので通知 - MessageResult messageResult = new MessageResult(); - messageResult.setMessage( - Resources.getInstance(locale).getResource("knowledge.notify.msg.desktop.to.comment", - StringUtils.abbreviate(knowledge.getTitle(), 80))); - messageResult.setResult(NotifyLogic.get().makeURL(knowledge.getKnowledgeId())); // Knowledgeへのリンク - return messageResult; - } - } - return null; - } -} diff --git a/src/main/java/org/support/project/knowledge/vo/StockKnowledge.java b/src/main/java/org/support/project/knowledge/vo/StockKnowledge.java index 0c015a2fc..65e4b4d0b 100644 --- a/src/main/java/org/support/project/knowledge/vo/StockKnowledge.java +++ b/src/main/java/org/support/project/knowledge/vo/StockKnowledge.java @@ -15,6 +15,8 @@ public class StockKnowledge extends KnowledgesEntity { private Participations participations; + private boolean viewed = false; + /** * Get stocks * @return the stocks @@ -44,6 +46,20 @@ public Participations getParticipations() { public void setParticipations(Participations participations) { this.participations = participations; } + + /** + * @return the viewed + */ + public boolean isViewed() { + return viewed; + } + + /** + * @param viewed the viewed to set + */ + public void setViewed(boolean viewed) { + this.viewed = viewed; + } } diff --git a/src/main/java/org/support/project/knowledge/vo/UserConfigs.java b/src/main/java/org/support/project/knowledge/vo/UserConfigs.java new file mode 100644 index 000000000..0146b564a --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/UserConfigs.java @@ -0,0 +1,81 @@ +package org.support.project.knowledge.vo; + +import java.io.Serializable; +import java.util.Locale; + +public class UserConfigs implements Serializable { + /** serialVersion */ + private static final long serialVersionUID = 1L; + private Locale locale = Locale.getDefault(); + /** タイムゾーン */ + private String timezone = "UTC"; + /** タイムゾーンオフセット(分) */ + private int timezoneOffset = 0; + /** テーマ */ + private String thema; + /** ハイライター */ + private int highlight; + /** + * @return the timezone + */ + public String getTimezone() { + return timezone; + } + /** + * @param timezone the timezone to set + */ + public void setTimezone(String timezone) { + this.timezone = timezone; + } + /** + * @return the timezoneOffset + */ + public int getTimezoneOffset() { + return timezoneOffset; + } + /** + * @param timezoneOffset the timezoneOffset to set + */ + public void setTimezoneOffset(int timezoneOffset) { + this.timezoneOffset = timezoneOffset; + } + /** + * @return the thema + */ + public String getThema() { + return thema; + } + /** + * @param thema the thema to set + */ + public void setThema(String thema) { + this.thema = thema; + } + /** + * @return the highlight + */ + public int getHighlight() { + return highlight; + } + /** + * @param highlight the highlight to set + */ + public void setHighlight(int highlight) { + this.highlight = highlight; + } + /** + * @return the locale + */ + public Locale getLocale() { + return locale; + } + /** + * @param locale the locale to set + */ + public void setLocale(Locale locale) { + this.locale = locale; + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java b/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java index d69c7238d..ef468a3c4 100644 --- a/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java +++ b/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java @@ -1,6 +1,7 @@ package org.support.project.knowledge.vo.api; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.List; public class Knowledge { @@ -26,7 +27,7 @@ public class Knowledge { private Timestamp updateDatetime; /** タグ */ - private List tags; + private List tags = new ArrayList<>(); /** テンプレート名 */ private String template; diff --git a/src/main/java/org/support/project/knowledge/vo/notification/CommentInsert.java b/src/main/java/org/support/project/knowledge/vo/notification/CommentInsert.java new file mode 100644 index 000000000..c09f5b106 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/notification/CommentInsert.java @@ -0,0 +1,35 @@ +package org.support.project.knowledge.vo.notification; + +public class CommentInsert extends KnowledgeUpdate { + + private String commentInsertUser; + private String commentContents; + + /** + * @return the commentInsertUser + */ + public String getCommentInsertUser() { + if (commentInsertUser == null) return ""; + return commentInsertUser; + } + /** + * @param commentInsertUser the commentInsertUser to set + */ + public void setCommentInsertUser(String commentInsertUser) { + this.commentInsertUser = commentInsertUser; + } + /** + * @return the commentContents + */ + public String getCommentContents() { + if (commentContents == null) return ""; + return commentContents; + } + /** + * @param commentContents the commentContents to set + */ + public void setCommentContents(String commentContents) { + this.commentContents = commentContents; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/notification/EventInformation.java b/src/main/java/org/support/project/knowledge/vo/notification/EventInformation.java new file mode 100644 index 000000000..ccc97be6b --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/notification/EventInformation.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.vo.notification; + +public class EventInformation extends KnowledgeUpdate { + + private int timing; + + /** + * @return the timing + */ + public int getTiming() { + return timing; + } + + /** + * @param timing the timing to set + */ + public void setTiming(int timing) { + this.timing = timing; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/notification/KnowledgeUpdate.java b/src/main/java/org/support/project/knowledge/vo/notification/KnowledgeUpdate.java new file mode 100644 index 000000000..068daeeab --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/notification/KnowledgeUpdate.java @@ -0,0 +1,45 @@ +package org.support.project.knowledge.vo.notification; + +public class KnowledgeUpdate { + private long knowledgeId; + private String knowledgeTitle; + private String updateUser; + /** + * @return the knowledgeId + */ + public long getKnowledgeId() { + return knowledgeId; + } + /** + * @param knowledgeId the knowledgeId to set + */ + public void setKnowledgeId(long knowledgeId) { + this.knowledgeId = knowledgeId; + } + /** + * @return the knowledgeTitle + */ + public String getKnowledgeTitle() { + if (knowledgeTitle == null) return ""; + return knowledgeTitle; + } + /** + * @param knowledgeTitle the knowledgeTitle to set + */ + public void setKnowledgeTitle(String knowledgeTitle) { + this.knowledgeTitle = knowledgeTitle; + } + /** + * @return the updateUser + */ + public String getUpdateUser() { + if (updateUser == null) return ""; + return updateUser; + } + /** + * @param updateUser the updateUser to set + */ + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } +} diff --git a/src/main/java/org/support/project/knowledge/vo/notification/LikeInsert.java b/src/main/java/org/support/project/knowledge/vo/notification/LikeInsert.java new file mode 100644 index 000000000..8e7e29abe --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/notification/LikeInsert.java @@ -0,0 +1,38 @@ +package org.support.project.knowledge.vo.notification; + +public class LikeInsert extends KnowledgeUpdate { + private String likeInsertUser; + + /** コメントにイイネが投稿された場合は、コメントのNoを保持 */ + private Long commentNo; + + /** + * @return the likeInsertUser + */ + public String getLikeInsertUser() { + if (likeInsertUser == null) return ""; + return likeInsertUser; + } + + /** + * @param likeInsertUser the likeInsertUser to set + */ + public void setLikeInsertUser(String likeInsertUser) { + this.likeInsertUser = likeInsertUser; + } + + /** + * @return the commentNo + */ + public Long getCommentNo() { + return commentNo; + } + + /** + * @param commentNo the commentNo to set + */ + public void setCommentNo(Long commentNo) { + this.commentNo = commentNo; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/notification/Participate.java b/src/main/java/org/support/project/knowledge/vo/notification/Participate.java new file mode 100644 index 000000000..eef12da91 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/notification/Participate.java @@ -0,0 +1,32 @@ +package org.support.project.knowledge.vo.notification; + +public class Participate extends KnowledgeUpdate { + /** 参加者 */ + private int participant; + /** 参加者のステータス */ + private int status; + /** + * @return the participant + */ + public int getParticipant() { + return participant; + } + /** + * @param participant the participant to set + */ + public void setParticipant(int participant) { + this.participant = participant; + } + /** + * @return the status + */ + public int getStatus() { + return status; + } + /** + * @param status the status to set + */ + public void setStatus(int status) { + this.status = status; + } +} diff --git a/src/main/java/org/support/project/knowledge/websocket/AggregateEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/AggregateEndpoint.java new file mode 100644 index 000000000..55ac44564 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/websocket/AggregateEndpoint.java @@ -0,0 +1,72 @@ +package org.support.project.knowledge.websocket; + +import java.io.IOException; +import java.util.List; + +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +import org.support.project.common.bat.JobResult; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.bat.AggregateBat; +import org.support.project.web.websocket.CallBatchEndpoint; +import org.support.project.web.websocket.EndpointConfigurator; + +import net.arnx.jsonic.JSONException; + +@ServerEndpoint(value = "/aggregate", configurator = EndpointConfigurator.class) +public class AggregateEndpoint extends CallBatchEndpoint { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AggregateEndpoint.class); + + @OnOpen + public void onOpen(Session session) throws IOException { + LOG.info("Endpoint instance: " + this.hashCode()); + if (!super.isAdmin(session)) { + session.close(); + } + } + + @OnClose + public void onClose(Session session) { + super.onClose(session); + } + + @OnMessage + public void onMessage(String text, Session session) throws JSONException, IOException { + LOG.info(text); + if (text.equals("START_PROCESS") && super.isAdmin(session)) { + setSendPlefix(""); + call(session, AggregateBat.class); + } + } + + + @OnError + public void onError(Throwable t) { + LOG.warn("websocket on error." + t.getClass().getName() + " : " + t.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.warn("websocket error -> ", t); + } + } + + @Override + public void finishJob(JobResult result, Class batch, List sessions) { + super.finishJob(result, batch, sessions); + for (Session session : sessions) { + if (!super.isAdmin(session)) { + return; + } + try { + session.close(); + } catch (IOException e) { + LOG.warn("websocket on error." + e.getClass().getName() + " : " + e.getMessage()); + } + } + } +} diff --git a/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java index 08df2c9cb..e46ea98d6 100644 --- a/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java +++ b/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java @@ -1,6 +1,7 @@ package org.support.project.knowledge.websocket; import java.io.IOException; +import java.util.List; import javax.websocket.OnClose; import javax.websocket.OnError; @@ -9,6 +10,7 @@ import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; +import org.support.project.common.bat.JobResult; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.knowledge.bat.CreateExportDataBat; @@ -34,7 +36,7 @@ public void onClose(Session session) { } @OnMessage - public void onMessage(String text) throws JSONException, IOException { + public void onMessage(String text, Session session) throws JSONException, IOException { } @OnError @@ -44,4 +46,8 @@ public void onError(Throwable t) { LOG.warn("websocket error -> ", t); } } + + @Override + public void finishJob(JobResult result, Class batch, List sessions) { + } } diff --git a/src/main/java/org/support/project/knowledge/websocket/MigrateEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/MigrateEndpoint.java new file mode 100644 index 000000000..d9f27555b --- /dev/null +++ b/src/main/java/org/support/project/knowledge/websocket/MigrateEndpoint.java @@ -0,0 +1,81 @@ +package org.support.project.knowledge.websocket; + +import java.io.IOException; +import java.util.List; + +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +import org.support.project.common.bat.JobResult; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.deploy.InitDB; +import org.support.project.web.dao.SystemsDao; +import org.support.project.web.entity.SystemsEntity; +import org.support.project.web.websocket.CallBatchEndpoint; +import org.support.project.web.websocket.EndpointConfigurator; + +import net.arnx.jsonic.JSONException; + +@ServerEndpoint(value = "/migrate", configurator = EndpointConfigurator.class) +public class MigrateEndpoint extends CallBatchEndpoint { + /** ログ */ + private static final Log LOG = LogFactory.getLog(ReindexingEndpoint.class); + + @OnOpen + public void onOpen(Session session) throws IOException { + LOG.info("Endpoint instance: " + this.hashCode()); + if (!super.isAdmin(session)) { + session.close(); + } + } + + @OnClose + public void onClose(Session session) { + super.onClose(session); + } + + @OnMessage + public void onMessage(String text, Session session) throws JSONException, IOException { + LOG.info(text); + if (text.equals("START_MIGRATE") && super.isAdmin(session)) { + setSendPlefix(""); + call(session, InitDB.class); + } + } + + + @OnError + public void onError(Throwable t) { + LOG.warn("websocket on error." + t.getClass().getName() + " : " + t.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.warn("websocket error -> ", t); + } + } + + @Override + public void finishJob(JobResult result, Class batch, List sessions) { + super.finishJob(result, batch, sessions); + SystemsEntity entity = SystemsDao.get().selectOnKey(AppConfig.get().getSystemName()); + if (entity != null) { + if (InitDB.CURRENT.equals(entity.getVersion())) { + AppConfig.get().setMaintenanceMode(false); + } + } + for (Session session : sessions) { + if (!super.isAdmin(session)) { + return; + } + try { + session.close(); + } catch (IOException e) { + LOG.warn("websocket on error." + e.getClass().getName() + " : " + e.getMessage()); + } + } + } +} diff --git a/src/main/java/org/support/project/knowledge/websocket/NotifyAction.java b/src/main/java/org/support/project/knowledge/websocket/NotifyAction.java index 806796eaf..78e1a6938 100644 --- a/src/main/java/org/support/project/knowledge/websocket/NotifyAction.java +++ b/src/main/java/org/support/project/knowledge/websocket/NotifyAction.java @@ -5,7 +5,7 @@ import org.support.project.common.exception.ArgumentException; import org.support.project.di.DI; import org.support.project.di.Instance; -import org.support.project.knowledge.vo.Notify; +import org.support.project.knowledge.logic.notification.DesktopNotification; @DI(instance = Instance.Singleton) public class NotifyAction extends Observable { @@ -17,7 +17,7 @@ public class NotifyAction extends Observable { */ @Override public void notifyObservers(Object arg) { - if (!(arg instanceof Notify)) { + if (!(arg instanceof DesktopNotification)) { if (arg == null) { throw new ArgumentException("notify is invalid. only Notify.class. notify is null"); } else { diff --git a/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java b/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java index d97b6fa6a..176a01800 100644 --- a/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java +++ b/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java @@ -9,7 +9,7 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; -import org.support.project.knowledge.vo.Notify; +import org.support.project.knowledge.logic.notification.DesktopNotification; import org.support.project.web.bean.LoginedUser; import org.support.project.web.bean.MessageResult; import org.support.project.web.websocket.EndpointConfigurator; @@ -56,15 +56,15 @@ public void update(Observable o, Object message) { } } - if (message instanceof Notify && loginuser != null) { - Notify notify = (Notify) message; + if (message instanceof DesktopNotification && loginuser != null) { + DesktopNotification notify = (DesktopNotification) message; MessageResult result = notify.getMessage(loginuser, locale); if (result != null) { - if (LOG.isInfoEnabled()) { + if (LOG.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("[Notify] ").append("User id: ").append(session.getUserPrincipal().getName()).append(" "); builder.append("Session id: ").append(session.getId()).append(" ").append(result.getMessage()); - LOG.info(builder.toString()); + LOG.debug(builder.toString()); } session.getBasicRemote().sendText(JSON.encode(result)); } diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index fc33c7adf..c10f8f89d 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -59,9 +59,9 @@ message.allready.started=Already started. message.confirm.delete=Are you sure you want to delete? # Common Label -label.version=v1.10.0 +label.version=v1.11.0 label.login=Sign in -label.previous = Previous +label.previous= Previous label.next=Next label.add=Add label.public=Public @@ -113,6 +113,11 @@ label.new=New label.initialize=Initialize label.move.up=Move Up label.move.down=Move Down +label.unread=Unread +label.read=Read +label.save.draft=Save draft +label.delete.draft=Delete draft +label.mark.all.as.read=Mark all as read label.public.view= [Public] label.protect.view= [Protection] @@ -175,7 +180,7 @@ knowledge.auth.label.password=Password knowledge.auth.title.forgot.password=Forgot password knowledge.auth.msg.forgot.password=Please enter the email address of your account knowledge.auth.label.back.to.signin=Back to Sign In -knowledge.auth.label.request.init.passwoed=you will send the password initialization mail +knowledge.auth.label.request.init.password=you will send the password initialization mail knowledge.auth.msg.accept.request=I have accepted the request of password initialization. Because we send an email for password initialization to
specified e-mail address, please complete the processing. knowledge.auth.msg.change.password=Please complete the initialization by entering the password for the account knowledge.auth.label.change.password=Password initialization @@ -310,12 +315,15 @@ knowledge.edit.set.image.path=ShowImage knowledge.edit.set.slide.path=SlideShow knowledge.edit.update.content=updated a content knowledge.edit.update.meta=Only meta information was updated (update notification is not sent) -knowledge.edit.image.upload=Upload a image width preview +knowledge.edit.image.upload=Upload an image with preview +knowledge.edit.do.not.update.timeline=Don't update timeline knowledge.delete.none=Knowledge to be deleted is not specified knowledge.likes.title=User list that was me press the "Like" knowledge.likes.list.label.empty=In this page, the user presses the "Like" did not have knowledge.likes.anonymous=Anonymous (not sign in user) +knowledge.likes.duplicate=Already registered(Register a "Like" is only one time) +knowledge.likes.required.signin=Sign in required. knowledge.histories.title=History knowledge.histories.list.label.empty=Empty @@ -338,7 +346,7 @@ knowledge.account.title=My Account knowledge.account.label.icon.drop= knowledge.account.label.icon.select=Select icon knowledge.account.label.password.msg=(input to change password) -knowledge.account.delete=Thank you for your use +knowledge.account.delete=Thank you for using knowledge.account.change.email=Change E-mail knowledge.account.changekey.title=Change E-mail knowledge.account.label.email=Mail address after change (A mail for change confirmation is sent to the address of the designation.) @@ -354,7 +362,7 @@ knowledge.account.info.ldap=This user is Ldap user. so you can update role only. knowledge.account.info.ldap2=You are Ldap user. so you can update role only. knowledge.account.targets=Default Targets knowledge.account.targets.select=Choose your default viewer target. -knowledge.account.delete.confirm=Are you sure you want to delete?
And this account's knowldge will delete? +knowledge.account.delete.confirm=Are you sure you want to delete?
And this account's knowldge will delete?
knowledge.account.delete.knowledge.keep=Keep knowledge.account.delete.knowledge.remove=Remove All @@ -369,7 +377,7 @@ knowledge.withdrawal.label.name=Removed User knowledge.registration.result.title=Registration Result knowledge.registration.msg.wait=I accept the registration.
use the start of the service, has become necessary to confirm the administrator. Please wait until the confirmation of
administrator. knowledge.registration.msg.mail=The invitation to the service I was sent. from the
received mail, you will be able to log in and complete the user registration.
-knowledge.registration.msg.mail.info=※ Note: Depending on the mailer, you may e-mail invitation will enter the junk e-mail. Please make sure that you are not reaching as junk e-mail. +knowledge.registration.msg.mail.info=*Note: Depending on the mailer, you may e-mail invitation will enter the junk e-mail. Please make sure that you are not reaching as junk e-mail. knowledge.config.title=User registration method specified knowledge.config.label.registration.method=The choice of procedure of user registration @@ -412,10 +420,13 @@ knowledge.config.mail=Mail transmission settings knowledge.config.system.title=System Config knowledge.config.system.label.url=Service URL knowledge.config.system.label.limit.attach=Maximum size of attached file (MB) -knowledge.config.system.open.title=Publishing Settings +knowledge.config.system.open.title=Publishing setting knowledge.config.system.open=No login is required knowledge.config.system.close=Login is required -knowledge.config.thema=Thema select +knowledge.config.system.like=Registration settings of "Like" +knowledge.config.system.like.many=Can be registered any number of times. +knowledge.config.system.like.onlyone=Can be registered only one. (Sign in required) +knowledge.config.thema=Theme select knowledge.config.thema.enable=Enable knowledge.config.thema.now=Now knowledge.config.highlight=Code Highlight @@ -484,7 +495,7 @@ knowledge.data.label.restore.msg.danger=When you run the restore will overwrite knowledge.data.label.restore.msg.info=A data base of default is made the target for the data which is being managed by this page. When changing the stock destination of data by connection previous change in the data base, it isn't made the target. Please manage a backup according to the use environment by yourself in that case. knowledge.data.label.active=database server status knowledge.data.label.active.msg=You can change the operating status of the database server. And when you want to back up and restore, please stop the database before shutting down the service. -knowledge.data.label.active.msg2=※Please refer to the stop when you shut down in the case of use in Docker. +knowledge.data.label.active.msg2=*Please refer to the stop when you shut down in the case of use in Docker. knowledge.data.label.active.msg3=And I have stopped DB when Tomcat stops, but will be Docker is stopped before DB stop, it will become a state that DB could not be closed properly. knowledge.data.label.active.msg4=Then you may such as the value of automatic numbering of the automatic next is funny. knowledge.data.label.active.status=Current state @@ -634,8 +645,8 @@ knowledge.ldap.msg.connect.success2=connect success. knowledge.ldap.msg.save.error=Can not be saved because the connection can not be confirmed. LDAP configuration, or connection confirmation ID / password is incorrect. knowledge.ldap.msg.save.success=Saved. knowledge.ldap.confirm.delete=Delete. is it OK? -knowledge.ldao.msg.config1=This config is deplicated.
Please use the Ldap Config2. -knowledge.ldao.msg.config2=The Ldap is the setting that you can log in with a user in the subtree.
Ldap Config1 can not log in the subtree of the user. +knowledge.ldap.msg.config1=This config is deplicated.
Please use the Ldap Config2. +knowledge.ldap.msg.config2=The Ldap is the setting that you can log in with a user in the subtree.
Ldap Config1 can not log in the subtree of the user. knowledge.ldap.label.config2.binddn=Bind DN knowledge.ldap.label.config2.password=Password knowledge.ldap.label.config2.basedn=BaseDN @@ -683,6 +694,7 @@ knowledge.template.label.name=Name knowledge.template.label.icon=Icon knowledge.template.label.icon.msg=(Choice from 'Font Awesome'.[http://fontawesome.io/icons/] e.g. fa-book) knowledge.template.label.description=Description +knowledge.template.label.initial.value=Initial value knowledge.template.label.not.editable=This template is the default template of the system. you can edit only description. knowledge.template.msg.not.delete=The default template (knowledge, bookmark) can not be deleted. knowledge.template.label.item=Item @@ -716,6 +728,8 @@ knowledge.stock.label.link=link to stock knowledge.language.title=Language +knowledge.admin.menu=System menu +knowledge.admin.backtomenu=Back to System menu knowledge.admin.logging.files=Log files knowledge.admin.logging.delete=Delete config knowledge.admin.logging.delete.info=When the setting is enabled, you can delete it to older than this number of days @@ -729,7 +743,10 @@ knowledge.analytics.msg.info=In this page, you will register the script for the knowledge.account.label.knowledge.count=Knowledge Count knowledge.account.label.like.count=Like Count knowledge.account.label.stock.count=Stock Count +knowledge.account.label.cp=Contribution Point knowledge.account.label.knowledges=Knowledges +knowledge.account.label.like=Likes +knowledge.account.label.activity=Activities knowledge.admin.notice.title=Message from service administrator knowledge.admin.notice.msg=Manage messages from administrator. @@ -763,7 +780,7 @@ knowledge.admin.mailhook.condition.limit.post.0=None knowledge.admin.mailhook.condition.limit.post.1=Only registered users knowledge.admin.mailhook.condition.limit.post.2=Only email address of a specify domain knowledge.admin.mailhook.condition.limit.param=Domain (If domain limit selected) -knowledge.admin.mailhook.info.1=Post from e-mail is a automation function for add knowledge. It is receive mail by regularly, and add knowledge if satisfy the conditions. +knowledge.admin.mailhook.info.1=Post from e-mail is an automation function for add knowledge. It is receive mail by regularly, and add knowledge if satisfy the conditions. knowledge.admin.mailhook.info.2=After the reception, all mails will delete in this mailbox. knowledge.admin.mailhook.info.3=For this reason, please prepare the e-mail address of this function only. knowledge.admin.mailhook.title.properties=Properties of mail. (Advanced option) @@ -773,7 +790,7 @@ knowledge.draft.list.empty=Empty List knowledge.draft.list.empty.title=Empty Title knowledge.draft.view.msg.not.editor=You are not editor this knowledge. because other knowledge editor clear your role on editors. -knowledge.custom.service.title=Service custmize +knowledge.custom.service.title=Service customize knowledge.custom.service.label.title=Label of service knowledge.custom.service.label.icon=Icon knowledge.custom.service.label.custom.html=Change a html of top page. (advanced options) @@ -828,3 +845,37 @@ knowledge.token.label.update=Update expiration date knowledge.token.label.delete=Delete Token knowledge.token.msg.copy=Copied +knowledge.notification.title=Notifications +knowledge.notification.list.all=All items +knowledge.notification.list.only.unread=Only unread +knowledge.notification.view.not.found=Data is not found on "{1}". + +knowledge.maintenance.status=Site is down for maintenance +knowledge.maintenance.do.migrate=Execute maintenance +knowledge.maintenance.do.migrate.no.login=Execute maintenance(only administrator) +knowledge.maintenance.migrate.title=Database migration +knowledge.maintenance.migrate.message=You can execute database migration. recommend to backup database data. + +knowledge.activity.type.11.do.insert=This user posted {1} +knowledge.activity.type.21.do.show=This user showed {1} +knowledge.activity.type.22.shown={1} was shown by {2} +knowledge.activity.type.31.do.like=This user liked {1} +knowledge.activity.type.32.liked={1} was liked by {2} +knowledge.activity.type.41.do.stock=This user stocked {1} +knowledge.activity.type.42.stocked={1} was stocked by {2} +knowledge.activity.type.51.do.ansewer=This user answered to survey on {1} +knowledge.activity.type.52.answered={1}'s survey was answered by {2} +knowledge.activity.type.61.do.join=This user registration event to {1} +knowledge.activity.type.62.joined={1}'s event was registered by {2} +knowledge.activity.type.101.do.post.public=This user posted {1} to Public +knowledge.activity.type.111.do.post.protect=This user posted {1} to Protect +knowledge.activity.type.121.do.post.private=This user posted {1} to Private +knowledge.activity.type.1011.do.comment.insert=This user posted comment to {1} +knowledge.activity.type.1031.do.comment.like=This user liked {1}'s comment +knowledge.activity.type.1032.comment.liked=This user's comment on {1} was liked by {2} + +knowledge.activity.type.13.inserted={1} was posted by {2} +knowledge.activity.type.23.shown={1} was shown by {2} + +knowledge.aggregate.title=ReAggregation +knowledge.aggregate.msg=ReAggregation Contribution Point and View count.
Since it takes quite a long time to execute, please execute it in a period with less access. diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index fbf528dd2..14d13c17d 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -59,7 +59,7 @@ message.allready.started=すでに開始済です message.confirm.delete=本当に削除しますか? # Common Label -label.version=v1.10.0 +label.version=v1.11.0 label.login=サインイン label.previous = 前へ label.next = 次へ @@ -113,6 +113,11 @@ label.new=新規作成 label.initialize=初期化 label.move.up=上へ移動 label.move.down=下へ移動 +label.unread=未読 +label.read=既読 +label.save.draft=下書き保存 +label.delete.draft=下書き削除 +label.mark.all.as.read=既読にする label.public.view= [公開] label.protect.view= [保護] @@ -175,7 +180,7 @@ knowledge.auth.label.password=パスワード knowledge.auth.title.forgot.password=パスワード忘れのリクエスト knowledge.auth.msg.forgot.password=アカウントのメールアドレスを入力してください knowledge.auth.label.back.to.signin=サインインへ戻る -knowledge.auth.label.request.init.passwoed=パスワード初期化メールを送信 +knowledge.auth.label.request.init.password=パスワード初期化メールを送信 knowledge.auth.msg.accept.request=パスワード初期化のリクエストを受け付けました。
指定のメールアドレスにパスワード初期化用のメールを送信しましたので、処理を完了してください。 knowledge.auth.msg.change.password=アカウントのパスワードを入力して初期化を完了してください knowledge.auth.label.change.password=パスワード初期化 @@ -311,11 +316,14 @@ knowledge.edit.set.slide.path=スライドショー knowledge.edit.update.content=内容を更新しました knowledge.edit.update.meta=属性情報のみ更新しました(更新の通知は送られません) knowledge.edit.image.upload=画像をアップロード +knowledge.edit.do.not.update.timeline=タイムラインを更新しない(軽微な修正) knowledge.delete.none=削除するナレッジが指定されていません knowledge.likes.title=「いいね!」を押してくれたユーザ一覧 knowledge.likes.list.label.empty=このページでは、「いいね!」を押したユーザはいませんでした knowledge.likes.anonymous=Anonymous(未ログインユーザ) +knowledge.likes.duplicate=登録済です(いいね!は一人一回登録できます) +knowledge.likes.required.signin=いいね!を登録できるのはサインインしたユーザのみです knowledge.histories.title=更新履歴 knowledge.histories.list.label.empty=データが存在しません。 @@ -415,6 +423,9 @@ knowledge.config.system.label.limit.attach=添付ファイルの最大サイズ knowledge.config.system.open.title=システムの公開設定 knowledge.config.system.open=公開情報などには、ログインしなくてもアクセス可能 knowledge.config.system.close=全ての機能には、ログインしないとアクセス不可 +knowledge.config.system.like=いいね!の登録設定 +knowledge.config.system.like.many=いいね!は何回でも押せる +knowledge.config.system.like.onlyone=いいね!一度きり押せる(未ログインユーザは押せない) knowledge.config.thema=テーマ選択 knowledge.config.thema.enable=有効にする knowledge.config.thema.now=現在のテーマ @@ -534,22 +545,22 @@ knowledge.notify.target=通知先 knowledge.notify.target.mail=メール通知 knowledge.notify.target.desktop=デスクトップ通知(Chrome/Firefoxのみ) knowledge.notify.conditions=通知する条件 -knowledge.notify.conditions.myitem.comment=自分が登録した投稿にコメントが登録されたら通知 -knowledge.notify.conditions.myitem.like=自分が登録した投稿に「いいね!」が追加されたら通知 -knowledge.notify.conditions.myitem.stock=自分が登録した投稿がストックされたら通知 -knowledge.notify.conditions.to.save=自分宛の投稿が更新されたら通知 -knowledge.notify.conditions.to.comment=自分宛の投稿にコメントが登録されたら通知 -knowledge.notify.conditions.to.ignore.public=自分宛の投稿で「公開」は除外 +knowledge.notify.conditions.myitem.comment=自分が登録した記事にコメントが登録されたら通知 +knowledge.notify.conditions.myitem.like=自分が登録した記事に「いいね!」が追加されたら通知 +knowledge.notify.conditions.myitem.stock=自分が登録した記事がストックされたら通知 +knowledge.notify.conditions.to.save=記事が登録/更新されたら通知 +knowledge.notify.conditions.to.comment=記事にコメントが登録されたら通知 +knowledge.notify.conditions.to.ignore.public=記事の登録通知で「公開」は除外 knowledge.notify.conditions.stock.save=ストックしたナレッジが更新されたら通知 knowledge.notify.conditions.stock.comment=ストックしたナレッジにコメントが登録されたら通知 -knowledge.notify.msg.desktop.myitem.comment=あなたが投稿したナレッジ {1} にコメントが投稿されました -knowledge.notify.msg.desktop.myitem.like=あなたが投稿したナレッジ {1} に「いいね!」が押されました -knowledge.notify.msg.desktop.myitem.stock=あなたが投稿したナレッジ {1} がストックされました -knowledge.notify.msg.desktop.to.insert=ナレッジ {1} が登録されました -knowledge.notify.msg.desktop.to.update=ナレッジ {1} が更新されました -knowledge.notify.msg.desktop.to.comment=ナレッジ {1} にコメントが投稿されました -knowledge.notify.msg.desktop.stoke.update=ストックしているナレッジ {1} が更新されました -knowledge.notify.msg.desktop.stoke.comment=ストックしているナレッジ {1} にコメントが投稿されました +knowledge.notify.msg.desktop.myitem.comment=あなたが登録した記事 {1} にコメントが投稿されました +knowledge.notify.msg.desktop.myitem.like=あなたが登録した記事 {1} に「いいね!」が押されました +knowledge.notify.msg.desktop.myitem.stock=あなたが登録した記事 {1} がストックされました +knowledge.notify.msg.desktop.to.insert=記事 {1} が登録されました +knowledge.notify.msg.desktop.to.update=記事 {1} が更新されました +knowledge.notify.msg.desktop.to.comment=記事 {1} にコメントが投稿されました +knowledge.notify.msg.desktop.stoke.update=ストックしている記事 {1} が更新されました +knowledge.notify.msg.desktop.stoke.comment=ストックしている記事 {1} にコメントが投稿されました knowledge.export.title=データをエクスポート knowledge.export.msg1=データをエクスポートします。(zip形式でダウンロード) @@ -683,6 +694,7 @@ knowledge.template.label.name=名称 knowledge.template.label.icon=アイコン knowledge.template.label.icon.msg=(Font Awesome[http://fontawesome.io/icons/]から選択してください。 e.g. fa-book) knowledge.template.label.description=説明 +knowledge.template.label.initial.value=初期値 knowledge.template.label.not.editable=このテンプレートはシステムのデフォルトのテンプレートです。項目の増減、テンプレートの削除は出来ません。 knowledge.template.msg.not.delete=デフォルトのテンプレート(knowledge,bookmark)は削除できません knowledge.template.label.item=項目 @@ -716,6 +728,8 @@ knowledge.stock.label.link=ストック管理画面へ移動。 knowledge.language.title=Language +knowledge.admin.menu=システム設定 +knowledge.admin.backtomenu=システム設定メニューへ戻る knowledge.admin.logging.files=ログファイル一覧 knowledge.admin.logging.delete=ログの保存期間(自動削除) knowledge.admin.logging.delete.info=設定を有効にすると、この日数以上経過すると削除します @@ -726,10 +740,13 @@ knowledge.analytics.title=アナリティクスの設定 knowledge.analytics.label.script=アナリティクス用のスクリプト knowledge.analytics.msg.info=GoogleAnalyticsやPiwikといったアクセス解析用のスクリプトを登録します。
ここで登録したスクリプトは、全ての画面に適用されます。 -knowledge.account.label.knowledge.count=ナレッジ登録件数 +knowledge.account.label.knowledge.count=ナレッジ投稿件数 knowledge.account.label.like.count=いいね!獲得件数 knowledge.account.label.stock.count=ストックされた件数 -knowledge.account.label.knowledges=このユーザが登録したナレッジ +knowledge.account.label.cp=Contribution Point +knowledge.account.label.knowledges=投稿 +knowledge.account.label.like=イイネした投稿 +knowledge.account.label.activity=活動状況 knowledge.admin.notice.title=全体メッセージ knowledge.admin.notice.msg=アクセスユーザに対し、管理者からメッセージを登録します @@ -827,3 +844,38 @@ knowledge.token.label.create=Tokenを生成する knowledge.token.label.update=有効期限を更新する knowledge.token.label.delete=Tokenを削除する knowledge.token.msg.copy=コピーしました + +knowledge.notification.title=通知 +knowledge.notification.list.all=すべて表示 +knowledge.notification.list.only.unread=未読のみ +knowledge.notification.view.not.found=「{1}」 にデータがありません + +knowledge.maintenance.status=メンテナンス中 +knowledge.maintenance.do.migrate=メンテナンス管理を実行 +knowledge.maintenance.do.migrate.no.login=メンテナンス管理を実行(管理者のみアクセス可能) +knowledge.maintenance.migrate.title=Database migration +knowledge.maintenance.migrate.message=DBのマイグレーションを実行します。事前にDBのバックアップを取ることをオススメします。 + +knowledge.activity.type.11.do.insert={1} の記事を投稿しました +knowledge.activity.type.21.do.show={1} の記事を参照しました +knowledge.activity.type.22.shown=このユーザが投稿した {1} の記事を、{2} が参照しました +knowledge.activity.type.31.do.like={1} の記事にいいね!を押しました +knowledge.activity.type.32.liked=このユーザが投稿した {1} の記事を、{2} がいいね!を押しました +knowledge.activity.type.41.do.stock={1} の記事をストックしました +knowledge.activity.type.42.stocked=このユーザが投稿した {1} の記事を、{2} がストックしました +knowledge.activity.type.51.do.ansewer={1} のアンケートに回答しました +knowledge.activity.type.52.answered=このユーザが投稿した {1} の記事のアンケートに、{2} が回答しました +knowledge.activity.type.61.do.join={1} のイベントに参加登録しました +knowledge.activity.type.62.joined=このユーザが投稿した {1} のイベントに、{2} が参加登録しました +knowledge.activity.type.101.do.post.public={1} の記事を「公開」で投稿しました +knowledge.activity.type.111.do.post.protect={1} の記事を「保護」で投稿しました +knowledge.activity.type.121.do.post.private={1} の記事を「非公開」で投稿しました +knowledge.activity.type.1011.do.comment.insert={1} の記事にコメントを登録しました +knowledge.activity.type.1031.do.comment.like={1} の記事のコメントにいいね!を押しました +knowledge.activity.type.1032.comment.liked=このユーザが投稿した {1} の記事のコメントに、{2} がいいね!を押しました + +knowledge.activity.type.13.inserted={1} の記事が、{2} によって投稿されました +knowledge.activity.type.23.shown={1} の記事を、{2} が参照しました + +knowledge.aggregate.title=再集計 +knowledge.aggregate.msg=Contribution Point や、参照回数などの数値を再集計します。
実行にはかなり時間がかかりますので、アクセスの少ない期間に実行してください。 diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index c75941cea..e90bbdae9 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -44,6 +44,13 @@ + + + + + + + diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all.sql index 05c99dcbc..d9fe88d5b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM ACCOUNT_IMAGES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all_with_pager.sql index 6f6c461dc..b4bb78832 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM ACCOUNT_IMAGES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all.sql index 9b8cb5f2b..67457d91a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM ACCOUNT_IMAGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all_with_pager.sql index b15971f09..00dc47770 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM ACCOUNT_IMAGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_delete.sql new file mode 100644 index 000000000..be3ba4fc8 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_delete.sql @@ -0,0 +1,4 @@ +DELETE FROM ACTIVITIES +WHERE +ACTIVITY_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_insert.sql new file mode 100644 index 000000000..995d8561a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_insert.sql @@ -0,0 +1,22 @@ +INSERT INTO ACTIVITIES +( +ACTIVITY_NO + , USER_ID + , KIND + , TARGET + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +DEFAULT + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all.sql new file mode 100644 index 000000000..3cc74a316 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM ACTIVITIES +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..bc56c5983 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM ACTIVITIES +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_on_key.sql new file mode 100644 index 000000000..b0b963e3a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_physical_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM ACTIVITIES + WHERE +ACTIVITY_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_raw_insert.sql new file mode 100644 index 000000000..3169468de --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_raw_insert.sql @@ -0,0 +1,22 @@ +INSERT INTO ACTIVITIES +( +ACTIVITY_NO + , USER_ID + , KIND + , TARGET + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all.sql new file mode 100644 index 000000000..acdb93dba --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM ACTIVITIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all_with_pager.sql new file mode 100644 index 000000000..d7a72ffd4 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM ACTIVITIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_count_all.sql new file mode 100644 index 000000000..199c26999 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM ACTIVITIES +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_on_key.sql new file mode 100644 index 000000000..7fd4c7d0b --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM ACTIVITIES + WHERE +ACTIVITY_NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_update.sql new file mode 100644 index 000000000..b490022e7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ActivitiesDao/ActivitiesDao_update.sql @@ -0,0 +1,13 @@ +UPDATE ACTIVITIES +SET + USER_ID = ? + , KIND = ? + , TARGET = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +ACTIVITY_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_delete.sql new file mode 100644 index 000000000..1245387a7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_delete.sql @@ -0,0 +1,4 @@ +DELETE FROM BADGES +WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_insert.sql new file mode 100644 index 000000000..6e6e992e8 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_insert.sql @@ -0,0 +1,26 @@ +INSERT INTO BADGES +( +NO + , NAME + , DISPLAY_TEXT + , DESCRIPTION + , IMAGE + , POINT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +DEFAULT + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all.sql new file mode 100644 index 000000000..b17af757e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM BADGES +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..4be7e5ffa --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM BADGES +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_on_key.sql new file mode 100644 index 000000000..1e0328d3c --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_physical_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM BADGES + WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_raw_insert.sql new file mode 100644 index 000000000..6135deb4d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_raw_insert.sql @@ -0,0 +1,26 @@ +INSERT INTO BADGES +( +NO + , NAME + , DISPLAY_TEXT + , DESCRIPTION + , IMAGE + , POINT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all.sql new file mode 100644 index 000000000..f1ae31120 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM BADGES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all_with_pager.sql new file mode 100644 index 000000000..32eb748e2 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM BADGES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_count_all.sql new file mode 100644 index 000000000..2a9f07b6d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM BADGES +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_on_key.sql new file mode 100644 index 000000000..4f1a4f87a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM BADGES + WHERE +NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_update.sql new file mode 100644 index 000000000..2cbd6ba3b --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/BadgesDao/BadgesDao_update.sql @@ -0,0 +1,15 @@ +UPDATE BADGES +SET + NAME = ? + , DISPLAY_TEXT = ? + , DESCRIPTION = ? + , IMAGE = ? + , POINT = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all.sql index cff77c4a1..2a882635e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM COMMENTS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all_with_pager.sql index f24694900..10e1969ad 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM COMMENTS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all.sql index 9eb803227..85f3cddc8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM COMMENTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all_with_pager.sql index 13b473781..15d797739 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM COMMENTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all.sql index dc88dde4b..4b37341fa 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM DRAFT_ITEM_VALUES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all_with_pager.sql index 4f4440c74..08d96ce3a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM DRAFT_ITEM_VALUES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all.sql index 8a6863a14..27e0ee3bd 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM DRAFT_ITEM_VALUES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all_with_pager.sql index cc17a2082..9c79a450f 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftItemValuesDao/DraftItemValuesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM DRAFT_ITEM_VALUES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all.sql index da016fc70..0b6da5ba1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM DRAFT_KNOWLEDGES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all_with_pager.sql index 8a6a8e269..53269d0a0 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM DRAFT_KNOWLEDGES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all.sql index 5a120a2e3..44c90e2bb 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM DRAFT_KNOWLEDGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all_with_pager.sql index bef5717f9..65d374e64 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/DraftKnowledgesDao/DraftKnowledgesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM DRAFT_KNOWLEDGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all.sql index 5fc15c5e3..d3652cd9e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM EVENTS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all_with_pager.sql index 1d7431868..786652b8a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM EVENTS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all.sql index 3ab913f89..e5d7da632 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM EVENTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all_with_pager.sql index a17c1dd65..759c4e703 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/EventsDao/EventsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM EVENTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql index 2ae9270f6..6e3c0699b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql @@ -3,5 +3,5 @@ FROM USERS INNER JOIN NOTIFY_CONFIGS ON (USERS.USER_ID = NOTIFY_CONFIGS.USER_ID) WHERE NOTIFY_CONFIGS.NOTIFY_MAIL = 1 AND NOTIFY_CONFIGS.TO_ITEM_SAVE = 1 -AND NOTIFY_CONFIGS.TO_ITEM_IGNORE_PUBLIC != 1 +AND (NOTIFY_CONFIGS.TO_ITEM_IGNORE_PUBLIC != 1 OR NOTIFY_CONFIGS.TO_ITEM_IGNORE_PUBLIC IS NULL) AND USERS.DELETE_FLAG != 1 diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all.sql index 51103ce9f..c61416e20 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM ITEM_CHOICES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all_with_pager.sql index 552054a79..9f62bd6bd 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM ITEM_CHOICES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all.sql index f8bd11b3e..4e361e439 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM ITEM_CHOICES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all_with_pager.sql index 5c08c1e32..fc952e1a8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ItemChoicesDao/ItemChoicesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM ITEM_CHOICES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all.sql index 4a5aa5b18..5b0b10105 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_EDIT_GROUPS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all_with_pager.sql index 15f675a44..7ddb83fa0 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_EDIT_GROUPS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all.sql index a5d58e789..d66f58541 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_EDIT_GROUPS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all_with_pager.sql index d682a9915..335bc46c8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditGroupsDao/KnowledgeEditGroupsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_EDIT_GROUPS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all.sql index 5952e4ec0..dcb01c1ef 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_EDIT_USERS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all_with_pager.sql index 3ab1ee664..ab77bd414 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_EDIT_USERS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all.sql index 873e8fed0..ea63bc117 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_EDIT_USERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all_with_pager.sql index decbb8817..e3cb3b46b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeEditUsersDao/KnowledgeEditUsersDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_EDIT_USERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all.sql index b4cf17aa9..9bd4613f0 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_FILES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all_with_pager.sql index 9b0d48881..dbd1f2747 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_FILES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all.sql index b76b0624b..1d2d6882b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_FILES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all_with_pager.sql index d2c530fb5..e3e7905ae 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_FILES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all.sql index 865195387..1c59cbf65 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_GROUPS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all_with_pager.sql index aac8b1817..a6213dbd5 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_GROUPS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all.sql index 9c0beab79..68c770c2e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_GROUPS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all_with_pager.sql index 5f3c4244f..2bb96212a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_GROUPS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql index d343d5899..c69c550c5 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_HISTORIES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all_with_pager.sql index eac6b6fa3..e53aa2891 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_HISTORIES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql index d646b1029..b581cbc26 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_HISTORIES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all_with_pager.sql index 58710fc5d..25e535d0a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_HISTORIES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all.sql index 31ff00706..3af609b6d 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_ITEM_VALUES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all_with_pager.sql index 33f03e067..fbbe3d8c8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_ITEM_VALUES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all.sql index 3d74ff94b..f15f7f345 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_ITEM_VALUES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all_with_pager.sql index 8d691d7cb..e9f5a4d09 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeItemValuesDao/KnowledgeItemValuesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_ITEM_VALUES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all.sql index 3c99636c5..73f783cc4 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_TAGS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all_with_pager.sql index 76146a855..2ac548fc8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_TAGS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all.sql index db26f8e55..0bf0a1f09 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_TAGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all_with_pager.sql index dd6d2371c..037d3b4a1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_TAGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all.sql index 807327e25..f8ce5b1b7 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGE_USERS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all_with_pager.sql index 869bca4c3..bceeef594 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_USERS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all.sql index e44aab5fe..20eef7b2c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGE_USERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all_with_pager.sql index f06c235f4..f55d07a63 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGE_USERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql index b6d05f0b4..d3768942d 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql @@ -8,8 +8,10 @@ KNOWLEDGE_ID , TAG_NAMES , LIKE_COUNT , COMMENT_COUNT + , VIEW_COUNT , TYPE_ID , NOTIFY_STATUS + , POINT , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -31,4 +33,6 @@ DEFAULT , ? , ? , ? + , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all.sql index 80d3e5083..fc9021de1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM KNOWLEDGES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all_with_pager.sql index 42e31d59a..c13f85dd3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql index ad7d0565e..3560bb8e9 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql @@ -8,8 +8,10 @@ KNOWLEDGE_ID , TAG_NAMES , LIKE_COUNT , COMMENT_COUNT + , VIEW_COUNT , TYPE_ID , NOTIFY_STATUS + , POINT , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -31,4 +33,6 @@ KNOWLEDGE_ID , ? , ? , ? + , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularity.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularity.sql index 7dc7e59f1..63db2a9be 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularity.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularity.sql @@ -2,13 +2,13 @@ SELECT KNOWLEDGES.* ,USERS.USER_NAME AS INSERT_USER_NAME ,UP_USER.USER_NAME AS UPDATE_USER_NAME - ,COUNT(LIKES.NO) AS LIKE_COUNT_ON_TERM + ,COALESCE(SUM(POINT_KNOWLEDGE_HISTORIES.POINT), 0) AS POINT_ON_TERM FROM KNOWLEDGES - LEFT OUTER JOIN LIKES + LEFT OUTER JOIN POINT_KNOWLEDGE_HISTORIES ON ( - KNOWLEDGES.KNOWLEDGE_ID = LIKES.KNOWLEDGE_ID - AND LIKES.INSERT_DATETIME BETWEEN ? AND ? + KNOWLEDGES.KNOWLEDGE_ID = POINT_KNOWLEDGE_HISTORIES.KNOWLEDGE_ID + AND POINT_KNOWLEDGE_HISTORIES.INSERT_DATETIME BETWEEN ? AND ? ) LEFT OUTER JOIN USERS ON USERS.USER_ID = KNOWLEDGES.INSERT_USER @@ -17,8 +17,10 @@ SELECT WHERE KNOWLEDGES.DELETE_FLAG = 0 GROUP BY - KNOWLEDGES.KNOWLEDGE_ID, USERS.USER_NAME, UP_USER.USER_NAME + KNOWLEDGES.KNOWLEDGE_ID + ,USERS.USER_NAME + ,UP_USER.USER_NAME ORDER BY - COUNT(LIKES.NO) DESC + POINT_ON_TERM DESC ,KNOWLEDGES.UPDATE_DATETIME DESC - LIMIT ? OFFSET ?; + LIMIT ? OFFSET ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularityWithAccessControl.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularityWithAccessControl.sql index db9f27ca7..71cf4835b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularityWithAccessControl.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularityWithAccessControl.sql @@ -2,13 +2,13 @@ SELECT KNOWLEDGES.* ,USERS.USER_NAME AS INSERT_USER_NAME ,UP_USER.USER_NAME AS UPDATE_USER_NAME - ,COUNT(LIKES.NO) AS LIKE_COUNT_ON_TERM + ,COALESCE(SUM(POINT_KNOWLEDGE_HISTORIES.POINT), 0) AS POINT_ON_TERM FROM KNOWLEDGES - LEFT OUTER JOIN LIKES + LEFT OUTER JOIN POINT_KNOWLEDGE_HISTORIES ON ( - KNOWLEDGES.KNOWLEDGE_ID = LIKES.KNOWLEDGE_ID - AND LIKES.INSERT_DATETIME BETWEEN ? AND ? + KNOWLEDGES.KNOWLEDGE_ID = POINT_KNOWLEDGE_HISTORIES.KNOWLEDGE_ID + AND POINT_KNOWLEDGE_HISTORIES.INSERT_DATETIME BETWEEN ? AND ? ) LEFT OUTER JOIN USERS ON USERS.USER_ID = KNOWLEDGES.INSERT_USER @@ -50,6 +50,6 @@ SELECT GROUP BY KNOWLEDGES.KNOWLEDGE_ID, USERS.USER_NAME, UP_USER.USER_NAME ORDER BY - COUNT(LIKES.NO) DESC + POINT_ON_TERM DESC ,KNOWLEDGES.UPDATE_DATETIME DESC LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all.sql index 83836cfcc..cf0889603 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all_with_pager.sql index 5784aca68..923c907fa 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_update.sql index e9e7eac9a..825629212 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_update.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_update.sql @@ -7,8 +7,10 @@ SET , TAG_NAMES = ? , LIKE_COUNT = ? , COMMENT_COUNT = ? + , VIEW_COUNT = ? , TYPE_ID = ? , NOTIFY_STATUS = ? + , POINT = ? , INSERT_USER = ? , INSERT_DATETIME = ? , UPDATE_USER = ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_delete.sql new file mode 100644 index 000000000..9e34e9a0f --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_delete.sql @@ -0,0 +1,4 @@ +DELETE FROM LIKE_COMMENTS +WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_insert.sql new file mode 100644 index 000000000..6984ae37f --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO LIKE_COMMENTS +( +NO + , COMMENT_NO + , LIKE_CLASS + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +DEFAULT + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all.sql new file mode 100644 index 000000000..ab3ca5e9a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM LIKE_COMMENTS +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..5af12b4a4 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM LIKE_COMMENTS +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_on_key.sql new file mode 100644 index 000000000..55e7e14af --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_physical_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM LIKE_COMMENTS + WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_raw_insert.sql new file mode 100644 index 000000000..2fcb38adb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO LIKE_COMMENTS +( +NO + , COMMENT_NO + , LIKE_CLASS + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_selectOnCommentNo.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_selectOnCommentNo.sql new file mode 100644 index 000000000..4e1f8de5b --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_selectOnCommentNo.sql @@ -0,0 +1,15 @@ +SELECT + LIKE_COMMENTS.*, + USERS.USER_NAME + FROM + LIKE_COMMENTS + LEFT OUTER JOIN USERS ON (LIKE_COMMENTS.INSERT_USER = USERS.USER_ID) + WHERE + LIKE_COMMENTS.COMMENT_NO = ? + AND LIKE_COMMENTS.DELETE_FLAG = 0 + ORDER BY + LIKE_COMMENTS.UPDATE_DATETIME DESC LIMIT ? OFFSET ?; + + + + diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all.sql new file mode 100644 index 000000000..47a16a313 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM LIKE_COMMENTS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all_with_pager.sql new file mode 100644 index 000000000..479bf92d3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM LIKE_COMMENTS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_count_all.sql new file mode 100644 index 000000000..9d31607b9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM LIKE_COMMENTS +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_on_key.sql new file mode 100644 index 000000000..226d633ff --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM LIKE_COMMENTS + WHERE +NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_update.sql new file mode 100644 index 000000000..cc87d9456 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_update.sql @@ -0,0 +1,12 @@ +UPDATE LIKE_COMMENTS +SET + COMMENT_NO = ? + , LIKE_CLASS = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql index 361503e62..5c88f0da5 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql @@ -2,6 +2,7 @@ INSERT INTO LIKES ( NO , KNOWLEDGE_ID + , LIKE_CLASS , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -15,4 +16,5 @@ DEFAULT , ? , ? , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all.sql index 6eafc36d9..dfa07252c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM LIKES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all_with_pager.sql index 1c8c02b4a..add355e85 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM LIKES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql index 2783621da..d3a49e61c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql @@ -2,6 +2,7 @@ INSERT INTO LIKES ( NO , KNOWLEDGE_ID + , LIKE_CLASS , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -15,4 +16,5 @@ NO , ? , ? , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all.sql index 79bbb0642..56da73612 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM LIKES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all_with_pager.sql index 5e8f556ce..1b3ff62f2 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM LIKES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_update.sql index 99fe0c150..72e6a98b8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_update.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_update.sql @@ -1,6 +1,7 @@ UPDATE LIKES SET KNOWLEDGE_ID = ? + , LIKE_CLASS = ? , INSERT_USER = ? , INSERT_DATETIME = ? , UPDATE_USER = ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all.sql index 751881b13..0cae96353 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM MAIL_HOOK_CONDITIONS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all_with_pager.sql index 2fce7f7ce..dd8f0c1cd 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_HOOK_CONDITIONS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all.sql index d26f458f6..16fa652a7 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_HOOK_CONDITIONS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all_with_pager.sql index 68c1ba998..96c6c2cac 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookConditionsDao/MailHookConditionsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM MAIL_HOOK_CONDITIONS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_delete.sql new file mode 100644 index 000000000..c7ea88beb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_delete.sql @@ -0,0 +1,6 @@ +DELETE FROM MAIL_HOOK_IGNORE_CONDITIONS +WHERE +CONDITION_NO = ? + AND HOOK_ID = ? + AND IGNORE_CONDITION_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_insert.sql new file mode 100644 index 000000000..69a692a00 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_insert.sql @@ -0,0 +1,24 @@ +INSERT INTO MAIL_HOOK_IGNORE_CONDITIONS +( +CONDITION_NO + , HOOK_ID + , IGNORE_CONDITION_NO + , CONDITION_KIND + , CONDITION + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all.sql new file mode 100644 index 000000000..774463af0 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..201f9da59 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_condition_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_condition_no.sql new file mode 100644 index 000000000..46bc77246 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_condition_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +CONDITION_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_hook_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_hook_id.sql new file mode 100644 index 000000000..97e5babf3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_hook_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +HOOK_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_ignore_condition_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_ignore_condition_no.sql new file mode 100644 index 000000000..7723258bc --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_ignore_condition_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +IGNORE_CONDITION_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_key.sql new file mode 100644 index 000000000..28fd46afe --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_physical_select_on_key.sql @@ -0,0 +1,6 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +CONDITION_NO = ? + AND HOOK_ID = ? + AND IGNORE_CONDITION_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_raw_insert.sql new file mode 100644 index 000000000..69a692a00 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_raw_insert.sql @@ -0,0 +1,24 @@ +INSERT INTO MAIL_HOOK_IGNORE_CONDITIONS +( +CONDITION_NO + , HOOK_ID + , IGNORE_CONDITION_NO + , CONDITION_KIND + , CONDITION + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all.sql new file mode 100644 index 000000000..1c25609c9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all_with_pager.sql new file mode 100644 index 000000000..5a443dde7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_count_all.sql new file mode 100644 index 000000000..60f550e7e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM MAIL_HOOK_IGNORE_CONDITIONS +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_condition_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_condition_no.sql new file mode 100644 index 000000000..b351b19f0 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_condition_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +CONDITION_NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_hook_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_hook_id.sql new file mode 100644 index 000000000..6dcddf1fa --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_hook_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +HOOK_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_ignore_condition_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_ignore_condition_no.sql new file mode 100644 index 000000000..ae71c6390 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_ignore_condition_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +IGNORE_CONDITION_NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_key.sql new file mode 100644 index 000000000..592fbd2ba --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_select_on_key.sql @@ -0,0 +1,6 @@ +SELECT * FROM MAIL_HOOK_IGNORE_CONDITIONS + WHERE +CONDITION_NO = ? + AND HOOK_ID = ? + AND IGNORE_CONDITION_NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_update.sql new file mode 100644 index 000000000..a803a807b --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHookIgnoreConditionsDao/MailHookIgnoreConditionsDao_update.sql @@ -0,0 +1,14 @@ +UPDATE MAIL_HOOK_IGNORE_CONDITIONS +SET + CONDITION_KIND = ? + , CONDITION = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +CONDITION_NO = ? + AND HOOK_ID = ? + AND IGNORE_CONDITION_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all.sql index 1f79ec4ba..6dd63c3f2 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM MAIL_HOOKS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all_with_pager.sql index 3a9e3be60..b696cca5e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_HOOKS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all.sql index 487a61997..8fe047012 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_HOOKS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all_with_pager.sql index baa251941..d8a1b7fda 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailHooksDao/MailHooksDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM MAIL_HOOKS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all.sql index 3de9feaf5..d51fe6edf 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM MAIL_LOCALE_TEMPLATES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all_with_pager.sql index 3e83de1c0..7a4f944ac 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_LOCALE_TEMPLATES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all.sql index da3eb9940..5eda535d3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_LOCALE_TEMPLATES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all_with_pager.sql index c39e67d11..aa2256a30 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM MAIL_LOCALE_TEMPLATES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all.sql index 521589bef..2a432aba1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM MAIL_POSTS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all_with_pager.sql index 65f5d0cf5..7ef1f4491 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_POSTS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all.sql index 217caa8a9..113b27e83 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_POSTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all_with_pager.sql index b51f174d9..a76903f9d 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPostsDao/MailPostsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM MAIL_POSTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql index ebdc6ad4b..973937acd 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM MAIL_PROPERTIES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql index a7c99c6a9..bef27148e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_PROPERTIES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql index 91b5059e6..206d7c05f 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_PROPERTIES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql index 20be0fa61..54c1a3b90 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM MAIL_PROPERTIES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all.sql index 9324bd15e..39a556ce3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM MAIL_TEMPLATES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all_with_pager.sql index bc7166145..6c4b64477 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_TEMPLATES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all.sql index 7acefcace..26cb0d58e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM MAIL_TEMPLATES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all_with_pager.sql index 5012a9ba6..fa22d0c0a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailTemplatesDao/MailTemplatesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM MAIL_TEMPLATES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_delete.sql new file mode 100644 index 000000000..1098a665e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_delete.sql @@ -0,0 +1,6 @@ +DELETE FROM NOTIFICATION_STATUS +WHERE +TARGET_ID = ? + AND TYPE = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_insert.sql new file mode 100644 index 000000000..8cc13cfa9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_insert.sql @@ -0,0 +1,22 @@ +INSERT INTO NOTIFICATION_STATUS +( +TARGET_ID + , TYPE + , USER_ID + , STATUS + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all.sql new file mode 100644 index 000000000..fecc7eacd --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM NOTIFICATION_STATUS +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..692c5cce6 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM NOTIFICATION_STATUS +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_id.sql new file mode 100644 index 000000000..ba388bba5 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_key.sql new file mode 100644 index 000000000..d5c980226 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_key.sql @@ -0,0 +1,6 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +TARGET_ID = ? + AND TYPE = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_target_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_target_id.sql new file mode 100644 index 000000000..c183fc2fa --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_target_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +TARGET_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_type.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_type.sql new file mode 100644 index 000000000..72d33dffb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_type.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +TYPE = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user.sql new file mode 100644 index 000000000..a8aba77e3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +USER = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user_id.sql new file mode 100644 index 000000000..551bd000e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_physical_select_on_user_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_raw_insert.sql new file mode 100644 index 000000000..8cc13cfa9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_raw_insert.sql @@ -0,0 +1,22 @@ +INSERT INTO NOTIFICATION_STATUS +( +TARGET_ID + , TYPE + , USER_ID + , STATUS + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all.sql new file mode 100644 index 000000000..84d4e3efb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM NOTIFICATION_STATUS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all_with_pager.sql new file mode 100644 index 000000000..1ff44cc6d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_count_all.sql new file mode 100644 index 000000000..aff8f34db --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM NOTIFICATION_STATUS +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_id.sql new file mode 100644 index 000000000..70f8092d8 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_key.sql new file mode 100644 index 000000000..c702833af --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_key.sql @@ -0,0 +1,6 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +TARGET_ID = ? + AND TYPE = ? + AND USER_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_target_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_target_id.sql new file mode 100644 index 000000000..25616e354 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_target_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +TARGET_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_type.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_type.sql new file mode 100644 index 000000000..92cf7d607 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_type.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +TYPE = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user.sql new file mode 100644 index 000000000..802ede629 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +USER = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user_id.sql new file mode 100644 index 000000000..bd9904403 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_select_on_user_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM NOTIFICATION_STATUS + WHERE +USER_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_update.sql new file mode 100644 index 000000000..caf9af8b5 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotificationStatusDao/NotificationStatusDao_update.sql @@ -0,0 +1,13 @@ +UPDATE NOTIFICATION_STATUS +SET + STATUS = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +TARGET_ID = ? + AND TYPE = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all.sql index 7efa15f35..1160b23eb 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM NOTIFY_CONFIGS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all_with_pager.sql index b079c2ecd..abfb51cce 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM NOTIFY_CONFIGS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all.sql index b5816a083..6326a8392 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM NOTIFY_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all_with_pager.sql index fd30f7386..831949d1a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM NOTIFY_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all.sql index 93682534c..cfc34e0ee 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM NOTIFY_QUEUES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all_with_pager.sql index 7873229a7..cd55e48e3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM NOTIFY_QUEUES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all.sql index e5efdad2b..a682db2d1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM NOTIFY_QUEUES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all_with_pager.sql index 72cbb0d88..bfb34d7e4 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM NOTIFY_QUEUES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all.sql index 65ef42da1..dc0687834 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM PARTICIPANTS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all_with_pager.sql index fe52c87b0..724efafda 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM PARTICIPANTS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all.sql index dcb1a4ec2..5d6b08ca5 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM PARTICIPANTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all_with_pager.sql index 10786f4a8..c76715ee2 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ParticipantsDao/ParticipantsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM PARTICIPANTS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all.sql index 1d5f064c4..c55a0acf5 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM PINS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all_with_pager.sql index b8592b739..c04f0bed1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM PINS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all.sql index 93f9c9001..50af119a1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM PINS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all_with_pager.sql index f9ac0fb5e..168f5c8f9 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PinsDao/PinsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM PINS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_delete.sql new file mode 100644 index 000000000..c5e58e3eb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_delete.sql @@ -0,0 +1,5 @@ +DELETE FROM POINT_KNOWLEDGE_HISTORIES +WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_insert.sql new file mode 100644 index 000000000..1daae0fd3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_insert.sql @@ -0,0 +1,28 @@ +INSERT INTO POINT_KNOWLEDGE_HISTORIES +( +HISTORY_NO + , KNOWLEDGE_ID + , ACTIVITY_NO + , TYPE + , POINT + , BEFORE_TOTAL + , TOTAL + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all.sql new file mode 100644 index 000000000..dcf926a57 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..fd313ad42 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_history_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_history_no.sql new file mode 100644 index 000000000..9c1667b97 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_history_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_key.sql new file mode 100644 index 000000000..c2d200af3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_knowledge_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_knowledge_id.sql new file mode 100644 index 000000000..5216a7c27 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_physical_select_on_knowledge_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES + WHERE +KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_raw_insert.sql new file mode 100644 index 000000000..1daae0fd3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_raw_insert.sql @@ -0,0 +1,28 @@ +INSERT INTO POINT_KNOWLEDGE_HISTORIES +( +HISTORY_NO + , KNOWLEDGE_ID + , ACTIVITY_NO + , TYPE + , POINT + , BEFORE_TOTAL + , TOTAL + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all.sql new file mode 100644 index 000000000..5d269ac93 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all_with_pager.sql new file mode 100644 index 000000000..9a1204373 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_count_all.sql new file mode 100644 index 000000000..c953d8f53 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM POINT_KNOWLEDGE_HISTORIES +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_history_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_history_no.sql new file mode 100644 index 000000000..a64adb685 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_history_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_key.sql new file mode 100644 index 000000000..bbbf73e0d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_knowledge_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_knowledge_id.sql new file mode 100644 index 000000000..91b7cd596 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_select_on_knowledge_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_KNOWLEDGE_HISTORIES + WHERE +KNOWLEDGE_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_update.sql new file mode 100644 index 000000000..ac82cb842 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointKnowledgeHistoriesDao/PointKnowledgeHistoriesDao_update.sql @@ -0,0 +1,16 @@ +UPDATE POINT_KNOWLEDGE_HISTORIES +SET + ACTIVITY_NO = ? + , TYPE = ? + , POINT = ? + , BEFORE_TOTAL = ? + , TOTAL = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_delete.sql new file mode 100644 index 000000000..354e1b214 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_delete.sql @@ -0,0 +1,5 @@ +DELETE FROM POINT_USER_HISTORIES +WHERE +HISTORY_NO = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_insert.sql new file mode 100644 index 000000000..b6fdc84a7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_insert.sql @@ -0,0 +1,28 @@ +INSERT INTO POINT_USER_HISTORIES +( +HISTORY_NO + , USER_ID + , ACTIVITY_NO + , TYPE + , POINT + , BEFORE_TOTAL + , TOTAL + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all.sql new file mode 100644 index 000000000..f3e595980 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM POINT_USER_HISTORIES +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..dd9233042 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM POINT_USER_HISTORIES +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_history_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_history_no.sql new file mode 100644 index 000000000..8e70af128 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_history_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_USER_HISTORIES + WHERE +HISTORY_NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_key.sql new file mode 100644 index 000000000..9431c3d68 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM POINT_USER_HISTORIES + WHERE +HISTORY_NO = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_user_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_user_id.sql new file mode 100644 index 000000000..b2675a637 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_physical_select_on_user_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_USER_HISTORIES + WHERE +USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_raw_insert.sql new file mode 100644 index 000000000..b6fdc84a7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_raw_insert.sql @@ -0,0 +1,28 @@ +INSERT INTO POINT_USER_HISTORIES +( +HISTORY_NO + , USER_ID + , ACTIVITY_NO + , TYPE + , POINT + , BEFORE_TOTAL + , TOTAL + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all.sql new file mode 100644 index 000000000..dd2d18683 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM POINT_USER_HISTORIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all_with_pager.sql new file mode 100644 index 000000000..c5d8eadcc --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_USER_HISTORIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_count_all.sql new file mode 100644 index 000000000..95d55869a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM POINT_USER_HISTORIES +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_history_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_history_no.sql new file mode 100644 index 000000000..9d9590055 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_history_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_USER_HISTORIES + WHERE +HISTORY_NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_key.sql new file mode 100644 index 000000000..1eb98437f --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM POINT_USER_HISTORIES + WHERE +HISTORY_NO = ? + AND USER_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_user_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_user_id.sql new file mode 100644 index 000000000..5f8c92072 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_select_on_user_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM POINT_USER_HISTORIES + WHERE +USER_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_update.sql new file mode 100644 index 000000000..10a951133 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/PointUserHistoriesDao_update.sql @@ -0,0 +1,16 @@ +UPDATE POINT_USER_HISTORIES +SET + ACTIVITY_NO = ? + , TYPE = ? + , POINT = ? + , BEFORE_TOTAL = ? + , TOTAL = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +HISTORY_NO = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date_h2.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date_h2.sql new file mode 100644 index 000000000..67ae8ea55 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date_h2.sql @@ -0,0 +1,28 @@ +SELECT + YMD + ,MAX(TOTAL) AS TOTAL + ,MIN(BEFORE_TOTAL) AS BEFORE + FROM + ( + SELECT + TO_CHAR(TIMESTAMPADD( + 'MINUTE' + ,? + ,INSERT_DATETIME + ), 'YYYYMMDD') AS YMD + ,TOTAL + ,BEFORE_TOTAL + FROM + POINT_USER_HISTORIES + WHERE + USER_ID = ? + AND INSERT_DATETIME > DATEADD( + 'DAY' + ,-32 + ,NOW() + ) + ) AS SUBQ + GROUP BY + YMD + ORDER BY + YMD; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date_postgresql.sql b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date_postgresql.sql new file mode 100644 index 000000000..0c33aed6b --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/PointUserHistoriesDao/select_point_history_by_date_postgresql.sql @@ -0,0 +1,20 @@ +SELECT + YMD + ,MAX(TOTAL) AS TOTAL + ,MIN(BEFORE_TOTAL) AS BEFORE + FROM + ( + SELECT + TO_CHAR(INSERT_DATETIME + CAST (? AS INTERVAL), 'YYYYMMDD') AS YMD + ,TOTAL + ,BEFORE_TOTAL + FROM + POINT_USER_HISTORIES + WHERE + USER_ID = ? + AND INSERT_DATETIME > NOW() + '-32 DAYS' + ) AS SUBQ + GROUP BY + YMD + ORDER BY + YMD; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all.sql index a2fae29db..5fcdfe052 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SERVICE_CONFIGS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all_with_pager.sql index 80b8fcfe4..287941361 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SERVICE_CONFIGS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all.sql index f0b7b3af5..83311d3fc 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SERVICE_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all_with_pager.sql index b0c65d984..5992ef29f 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceConfigsDao/ServiceConfigsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SERVICE_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all.sql index c2742dce3..f92fe405e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SERVICE_LOCALE_CONFIGS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all_with_pager.sql index 01e2470d3..18c7740d2 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SERVICE_LOCALE_CONFIGS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all.sql index 0de3d42e5..e2c839120 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SERVICE_LOCALE_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all_with_pager.sql index 40c4d4157..5d31741ad 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ServiceLocaleConfigsDao/ServiceLocaleConfigsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SERVICE_LOCALE_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all.sql index 5a3b9b827..286ff6de1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM STOCK_KNOWLEDGES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all_with_pager.sql index f18418b4f..9a83dd42d 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM STOCK_KNOWLEDGES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all.sql index 368b5477c..270d613d9 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM STOCK_KNOWLEDGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all_with_pager.sql index 3897cf73d..ddb52a4e1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StockKnowledgesDao/StockKnowledgesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM STOCK_KNOWLEDGES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all.sql index 08bf43ad8..22bfcb081 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM STOCKS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all_with_pager.sql index 782f3c3ba..bc6417e51 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM STOCKS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all.sql index 223478509..728acc91c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM STOCKS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all_with_pager.sql index 00a05d7ca..48747e5f3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM STOCKS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all.sql index 688165e03..3496f3812 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SURVEY_ANSWERS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all_with_pager.sql index 920aa2768..2e4520470 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_ANSWERS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all.sql index b55bb41b9..b689ac79e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_ANSWERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all_with_pager.sql index 7295ee4f1..bf83cc1ea 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyAnswersDao/SurveyAnswersDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SURVEY_ANSWERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all.sql index cbcfb099c..f45ad33a2 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SURVEY_CHOICES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all_with_pager.sql index f5da780b6..453d80bbb 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_CHOICES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all.sql index 302e5fb15..88c8f7f4a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_CHOICES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all_with_pager.sql index 3e14b4ff8..9add32f50 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyChoicesDao/SurveyChoicesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SURVEY_CHOICES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all.sql index bb4ecfda2..0398829e7 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SURVEY_ITEM_ANSWERS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all_with_pager.sql index 5da5b9fcb..862d4d143 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_ITEM_ANSWERS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all.sql index 911883289..de7d43064 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_ITEM_ANSWERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all_with_pager.sql index 7b4f30d02..c59b4076c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemAnswersDao/SurveyItemAnswersDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SURVEY_ITEM_ANSWERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all.sql index 6f4724c6d..ebfcbe64c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SURVEY_ITEMS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all_with_pager.sql index bedb3c232..fa8f7d29b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_ITEMS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all.sql index 6e462336a..44868f7a3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEY_ITEMS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all_with_pager.sql index a943b170c..276c68d47 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveyItemsDao/SurveyItemsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SURVEY_ITEMS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all.sql index 3e48ed5f8..4de782d95 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM SURVEYS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all_with_pager.sql index 6500107ce..c61836dfa 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEYS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all.sql index 68ea205c7..0dd9e2c06 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM SURVEYS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all_with_pager.sql index 90b8d9e5b..5eb1c8192 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM SURVEYS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all.sql index 0e8fa2bf5..199fbf136 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM TAGS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all_with_pager.sql index f7f5b4eb4..ed0923d51 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM TAGS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all.sql index 6caa5ff3f..98980af47 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM TAGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all_with_pager.sql index b5e442b6a..ba0394559 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM TAGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_insert.sql index 50cdf9dd6..de0c2c128 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_insert.sql @@ -5,6 +5,7 @@ ITEM_NO , ITEM_NAME , ITEM_TYPE , DESCRIPTION + , INITIAL_VALUE , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -21,4 +22,5 @@ ITEM_NO , ? , ? , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all.sql index 998e37de2..acc8d942c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM TEMPLATE_ITEMS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all_with_pager.sql index 8f5cb2908..1ce066257 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM TEMPLATE_ITEMS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_raw_insert.sql index 50cdf9dd6..de0c2c128 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_raw_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_raw_insert.sql @@ -5,6 +5,7 @@ ITEM_NO , ITEM_NAME , ITEM_TYPE , DESCRIPTION + , INITIAL_VALUE , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -21,4 +22,5 @@ ITEM_NO , ? , ? , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all.sql index aa87cd125..c377b9fed 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM TEMPLATE_ITEMS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all_with_pager.sql index 9dda3c85e..a43f889ba 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM TEMPLATE_ITEMS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_update.sql index 4f7f156e4..20cba5d01 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_update.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateItemsDao/TemplateItemsDao_update.sql @@ -3,6 +3,7 @@ SET ITEM_NAME = ? , ITEM_TYPE = ? , DESCRIPTION = ? + , INITIAL_VALUE = ? , INSERT_USER = ? , INSERT_DATETIME = ? , UPDATE_USER = ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_insert.sql index 48ba4feaa..5ad1df82e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_insert.sql @@ -4,6 +4,7 @@ TYPE_ID , TYPE_NAME , TYPE_ICON , DESCRIPTION + , INITIAL_VALUE , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -19,4 +20,5 @@ DEFAULT , ? , ? , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all.sql index 87f5440ef..f289b8ce1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM TEMPLATE_MASTERS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all_with_pager.sql index 1e788b305..16fa79cb1 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM TEMPLATE_MASTERS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_raw_insert.sql index 0c51f5ecc..ad00cad89 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_raw_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_raw_insert.sql @@ -4,6 +4,7 @@ TYPE_ID , TYPE_NAME , TYPE_ICON , DESCRIPTION + , INITIAL_VALUE , INSERT_USER , INSERT_DATETIME , UPDATE_USER @@ -19,4 +20,5 @@ TYPE_ID , ? , ? , ? + , ? ); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all.sql index 2f4751cb6..703b44581 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM TEMPLATE_MASTERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all_with_pager.sql index 983b18b6f..33d760355 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM TEMPLATE_MASTERS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_update.sql index e3388f0f4..7f2ad83b6 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_update.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_update.sql @@ -3,6 +3,7 @@ SET TYPE_NAME = ? , TYPE_ICON = ? , DESCRIPTION = ? + , INITIAL_VALUE = ? , INSERT_USER = ? , INSERT_DATETIME = ? , UPDATE_USER = ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql index 7fa82fc05..e6066449c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM TOKENS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql index b704def52..50f99adfa 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM TOKENS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql index d3cb05f49..2ef2dce3a 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM TOKENS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql index 1787498bd..3db81a7a8 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM TOKENS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_delete.sql new file mode 100644 index 000000000..764be295d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_delete.sql @@ -0,0 +1,5 @@ +DELETE FROM USER_BADGES +WHERE +NO = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_insert.sql new file mode 100644 index 000000000..85e3dfebe --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO USER_BADGES +( +NO + , USER_ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all.sql new file mode 100644 index 000000000..312c4b02a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM USER_BADGES +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..a07313184 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM USER_BADGES +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_key.sql new file mode 100644 index 000000000..e9763e138 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM USER_BADGES + WHERE +NO = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_no.sql new file mode 100644 index 000000000..6d824b86d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM USER_BADGES + WHERE +NO = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_user_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_user_id.sql new file mode 100644 index 000000000..326332e4d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_physical_select_on_user_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM USER_BADGES + WHERE +USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_raw_insert.sql new file mode 100644 index 000000000..85e3dfebe --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_raw_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO USER_BADGES +( +NO + , USER_ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all.sql new file mode 100644 index 000000000..d2548e8dd --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM USER_BADGES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all_with_pager.sql new file mode 100644 index 000000000..971425eeb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM USER_BADGES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME %s +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_count_all.sql new file mode 100644 index 000000000..f8d6d444a --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM USER_BADGES +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_key.sql new file mode 100644 index 000000000..3268f3642 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM USER_BADGES + WHERE +NO = ? + AND USER_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_no.sql new file mode 100644 index 000000000..8c7789e96 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_no.sql @@ -0,0 +1,4 @@ +SELECT * FROM USER_BADGES + WHERE +NO = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_user_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_user_id.sql new file mode 100644 index 000000000..420fcb6dc --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_select_on_user_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM USER_BADGES + WHERE +USER_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_update.sql new file mode 100644 index 000000000..4e7b159bb --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/UserBadgesDao/UserBadgesDao_update.sql @@ -0,0 +1,11 @@ +UPDATE USER_BADGES +SET + INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +NO = ? + AND USER_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all.sql index f1fd776a2..6458998a9 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM VIEW_HISTORIES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all_with_pager.sql index 1b6e981cb..7b35865fa 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM VIEW_HISTORIES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all.sql index 77eb26044..cd276008e 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM VIEW_HISTORIES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all_with_pager.sql index 06f9c9472..c292e2788 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM VIEW_HISTORIES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all.sql index db5d760cf..752b1a715 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM VOTES -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all_with_pager.sql index 3f5340933..314ffb518 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM VOTES -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all.sql index 917e7c1ca..b24b56c74 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM VOTES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all_with_pager.sql index c73001927..405a2063c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM VOTES WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all.sql index e86af8ba3..9a33ff531 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM WEBHOOK_CONFIGS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all_with_pager.sql index 9cf9036ec..1849952b4 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM WEBHOOK_CONFIGS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all.sql index 71f2f9726..29fb81048 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM WEBHOOK_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all_with_pager.sql index f886be5cd..c8c10d953 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhookConfigsDao/WebhookConfigsDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM WEBHOOK_CONFIGS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all.sql index 063debb21..4eeeece46 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all.sql @@ -1,2 +1,2 @@ SELECT * FROM WEBHOOKS -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all_with_pager.sql index 08c0b7067..2214e3a73 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_physical_select_all_with_pager.sql @@ -1,3 +1,3 @@ SELECT * FROM WEBHOOKS -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all.sql index 0b4ba969b..4d09aa4a4 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all.sql @@ -1,3 +1,3 @@ SELECT * FROM WEBHOOKS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC; +ORDER BY INSERT_DATETIME %s; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all_with_pager.sql index 03192ce1e..0a94e7fc3 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all_with_pager.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/WebhooksDao/WebhooksDao_select_all_with_pager.sql @@ -1,4 +1,4 @@ SELECT * FROM WEBHOOKS WHERE DELETE_FLAG = 0 -ORDER BY INSERT_DATETIME DESC +ORDER BY INSERT_DATETIME %s LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/database/ddl.sql b/src/main/resources/org/support/project/knowledge/database/ddl.sql index aa7ff4623..8b0e9fe1f 100644 --- a/src/main/resources/org/support/project/knowledge/database/ddl.sql +++ b/src/main/resources/org/support/project/knowledge/database/ddl.sql @@ -1,3 +1,152 @@ +-- いいねの通知状態 +drop table if exists NOTIFICATION_STATUS cascade; + +create table NOTIFICATION_STATUS ( + TYPE integer not null + , TARGET_ID bigint not null + , USER_ID integer not null + , STATUS integer + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint NOTIFICATION_STATUS_PKC primary key (TYPE,TARGET_ID,USER_ID) +) ; + +-- メールから投稿の際の除外条件 +drop table if exists MAIL_HOOK_IGNORE_CONDITIONS cascade; + +create table MAIL_HOOK_IGNORE_CONDITIONS ( + HOOK_ID INTEGER not null + , CONDITION_NO integer not null + , IGNORE_CONDITION_NO integer not null + , CONDITION_KIND integer not null + , CONDITION character varying(256) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint MAIL_HOOK_IGNORE_CONDITIONS_PKC primary key (HOOK_ID,CONDITION_NO,IGNORE_CONDITION_NO) +) ; + +-- ユーザのポイント獲得履歴 +drop table if exists POINT_USER_HISTORIES cascade; + +create table POINT_USER_HISTORIES ( + USER_ID INTEGER not null + , HISTORY_NO BIGINT not null + , ACTIVITY_NO BIGINT not null + , TYPE integer not null + , POINT integer not null + , BEFORE_TOTAL integer not null + , TOTAL integer not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint POINT_USER_HISTORIES_PKC primary key (USER_ID,HISTORY_NO) +) ; + +create index IDX_POINT_USER_HISTORIES_INSERT_DATETIME + on POINT_USER_HISTORIES(INSERT_DATETIME); + +-- ナレッジのポイント獲得履歴 +drop table if exists POINT_KNOWLEDGE_HISTORIES cascade; + +create table POINT_KNOWLEDGE_HISTORIES ( + KNOWLEDGE_ID BIGINT not null + , HISTORY_NO BIGINT not null + , ACTIVITY_NO BIGINT not null + , TYPE integer not null + , POINT integer not null + , BEFORE_TOTAL integer not null + , TOTAL integer not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint POINT_KNOWLEDGE_HISTORIES_PKC primary key (KNOWLEDGE_ID,HISTORY_NO) +) ; + +create index IDX_POINT_KNOWLEDGE_HISTORIES_INSERT_DATETIME + on POINT_KNOWLEDGE_HISTORIES(INSERT_DATETIME); + +-- ユーザの称号 +drop table if exists USER_BADGES cascade; + +create table USER_BADGES ( + USER_ID INTEGER not null + , NO INTEGER not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint USER_BADGES_PKC primary key (USER_ID,NO) +) ; + +-- アクティビティ +drop table if exists ACTIVITIES cascade; + +create table ACTIVITIES ( + ACTIVITY_NO BIGSERIAL not null + , USER_ID INTEGER not null + , KIND integer not null + , TARGET character varying(64) not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint ACTIVITIES_PKC primary key (ACTIVITY_NO) +) ; + +create index IDX_ACTIVITIES_USER_ID + on ACTIVITIES(USER_ID); + +create index IDX_ACTIVITIES_KIND_TARGET + on ACTIVITIES(KIND,TARGET); + +-- 称号 +drop table if exists BADGES cascade; + +create table BADGES ( + NO SERIAL not null + , NAME character varying(128) not null + , DISPLAY_TEXT character varying(32) not null + , DESCRIPTION text + , IMAGE character varying(64) + , POINT integer + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint BADGES_PKC primary key (NO) +) ; + +-- コメントのイイネ +drop table if exists LIKE_COMMENTS cascade; + +create table LIKE_COMMENTS ( + NO BIGSERIAL not null + , COMMENT_NO bigint not null + , LIKE_CLASS integer default 1 + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint LIKE_COMMENTS_PKC primary key (NO) +) ; + +create index IDX_LIKE_COMMENTS_COMMENT_NO + on LIKE_COMMENTS(COMMENT_NO); + -- 認証トークン drop table if exists TOKENS cascade; @@ -411,6 +560,7 @@ create table TEMPLATE_MASTERS ( , TYPE_NAME character varying(256) not null , TYPE_ICON character varying(64) , DESCRIPTION character varying(1024) + , INITIAL_VALUE text , INSERT_USER integer , INSERT_DATETIME timestamp , UPDATE_USER integer @@ -428,6 +578,7 @@ create table TEMPLATE_ITEMS ( , ITEM_NAME character varying(32) not null , ITEM_TYPE integer not null , DESCRIPTION character varying(1024) + , INITIAL_VALUE text , INSERT_USER integer , INSERT_DATETIME timestamp , UPDATE_USER integer @@ -551,6 +702,7 @@ drop table if exists LIKES cascade; create table LIKES ( NO BIGSERIAL not null , KNOWLEDGE_ID bigint not null + , LIKE_CLASS integer default 1 , INSERT_USER integer , INSERT_DATETIME timestamp , UPDATE_USER integer @@ -617,6 +769,12 @@ create table VIEW_HISTORIES ( create index IDX_VIEW_HISTORIES_KNOWLEDGE_ID on VIEW_HISTORIES(KNOWLEDGE_ID); +create index IDX_VIEW_HISTORIES_INSERT_USER + on VIEW_HISTORIES(INSERT_USER); + +create index IDX_VIEW_HISTORIES_KNOWLEDGE_ID_INSERT_USER + on VIEW_HISTORIES(KNOWLEDGE_ID,INSERT_USER); + -- ストックしたナレッジ drop table if exists STOCK_KNOWLEDGES cascade; @@ -723,8 +881,10 @@ create table KNOWLEDGES ( , TAG_NAMES text , LIKE_COUNT bigint , COMMENT_COUNT integer + , VIEW_COUNT bigint , TYPE_ID integer , NOTIFY_STATUS integer + , POINT integer default 0 not null , INSERT_USER integer , INSERT_DATETIME timestamp , UPDATE_USER integer @@ -733,6 +893,100 @@ create table KNOWLEDGES ( , constraint KNOWLEDGES_PKC primary key (KNOWLEDGE_ID) ) ; +comment on table NOTIFICATION_STATUS is 'いいねの通知状態'; +comment on column NOTIFICATION_STATUS.TYPE is '種類'; +comment on column NOTIFICATION_STATUS.TARGET_ID is 'ターゲットのID'; +comment on column NOTIFICATION_STATUS.USER_ID is '登録者'; +comment on column NOTIFICATION_STATUS.STATUS is '通知の状態'; +comment on column NOTIFICATION_STATUS.INSERT_USER is '登録ユーザ'; +comment on column NOTIFICATION_STATUS.INSERT_DATETIME is '登録日時'; +comment on column NOTIFICATION_STATUS.UPDATE_USER is '更新ユーザ'; +comment on column NOTIFICATION_STATUS.UPDATE_DATETIME is '更新日時'; +comment on column NOTIFICATION_STATUS.DELETE_FLAG is '削除フラグ'; + +comment on table MAIL_HOOK_IGNORE_CONDITIONS is 'メールから投稿の際の除外条件'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.HOOK_ID is 'HOOK_ID'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.CONDITION_NO is 'CONDITION_NO'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.IGNORE_CONDITION_NO is 'IGNORE_CONDITION_NO'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.CONDITION_KIND is '条件の種類 1:宛先が「条件文字」であった場合'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.CONDITION is '条件の文字'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.INSERT_USER is '登録ユーザ'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.INSERT_DATETIME is '登録日時'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.UPDATE_USER is '更新ユーザ'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.UPDATE_DATETIME is '更新日時'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.DELETE_FLAG is '削除フラグ'; + +comment on table POINT_USER_HISTORIES is 'ユーザのポイント獲得履歴'; +comment on column POINT_USER_HISTORIES.USER_ID is 'ユーザID'; +comment on column POINT_USER_HISTORIES.HISTORY_NO is '履歴番号'; +comment on column POINT_USER_HISTORIES.ACTIVITY_NO is 'アクティビティ番号'; +comment on column POINT_USER_HISTORIES.TYPE is '獲得のタイプ'; +comment on column POINT_USER_HISTORIES.POINT is '獲得ポイント'; +comment on column POINT_USER_HISTORIES.BEFORE_TOTAL is '獲得前ポイント'; +comment on column POINT_USER_HISTORIES.TOTAL is 'トータルポイント'; +comment on column POINT_USER_HISTORIES.INSERT_USER is '登録ユーザ'; +comment on column POINT_USER_HISTORIES.INSERT_DATETIME is '登録日時'; +comment on column POINT_USER_HISTORIES.UPDATE_USER is '更新ユーザ'; +comment on column POINT_USER_HISTORIES.UPDATE_DATETIME is '更新日時'; +comment on column POINT_USER_HISTORIES.DELETE_FLAG is '削除フラグ'; + +comment on table POINT_KNOWLEDGE_HISTORIES is 'ナレッジのポイント獲得履歴'; +comment on column POINT_KNOWLEDGE_HISTORIES.KNOWLEDGE_ID is 'ナレッジID'; +comment on column POINT_KNOWLEDGE_HISTORIES.HISTORY_NO is '履歴番号'; +comment on column POINT_KNOWLEDGE_HISTORIES.ACTIVITY_NO is 'アクティビティ番号'; +comment on column POINT_KNOWLEDGE_HISTORIES.TYPE is '獲得のタイプ'; +comment on column POINT_KNOWLEDGE_HISTORIES.POINT is '獲得ポイント'; +comment on column POINT_KNOWLEDGE_HISTORIES.BEFORE_TOTAL is '獲得前ポイント'; +comment on column POINT_KNOWLEDGE_HISTORIES.TOTAL is 'トータルポイント'; +comment on column POINT_KNOWLEDGE_HISTORIES.INSERT_USER is '登録ユーザ'; +comment on column POINT_KNOWLEDGE_HISTORIES.INSERT_DATETIME is '登録日時'; +comment on column POINT_KNOWLEDGE_HISTORIES.UPDATE_USER is '更新ユーザ'; +comment on column POINT_KNOWLEDGE_HISTORIES.UPDATE_DATETIME is '更新日時'; +comment on column POINT_KNOWLEDGE_HISTORIES.DELETE_FLAG is '削除フラグ'; + +comment on table USER_BADGES is 'ユーザの称号'; +comment on column USER_BADGES.USER_ID is 'ユーザID'; +comment on column USER_BADGES.NO is '番号'; +comment on column USER_BADGES.INSERT_USER is '登録ユーザ'; +comment on column USER_BADGES.INSERT_DATETIME is '登録日時'; +comment on column USER_BADGES.UPDATE_USER is '更新ユーザ'; +comment on column USER_BADGES.UPDATE_DATETIME is '更新日時'; +comment on column USER_BADGES.DELETE_FLAG is '削除フラグ'; + +comment on table ACTIVITIES is 'アクティビティ'; +comment on column ACTIVITIES.ACTIVITY_NO is 'アクティビティ番号'; +comment on column ACTIVITIES.USER_ID is 'イベントをおこしたユーザ'; +comment on column ACTIVITIES.KIND is 'アクティビティの種類'; +comment on column ACTIVITIES.TARGET is 'ターゲットID'; +comment on column ACTIVITIES.INSERT_USER is '登録ユーザ'; +comment on column ACTIVITIES.INSERT_DATETIME is '登録日時'; +comment on column ACTIVITIES.UPDATE_USER is '更新ユーザ'; +comment on column ACTIVITIES.UPDATE_DATETIME is '更新日時'; +comment on column ACTIVITIES.DELETE_FLAG is '削除フラグ'; + +comment on table BADGES is '称号'; +comment on column BADGES.NO is '番号'; +comment on column BADGES.NAME is '名称'; +comment on column BADGES.DISPLAY_TEXT is '表示名'; +comment on column BADGES.DESCRIPTION is '説明'; +comment on column BADGES.IMAGE is '画像'; +comment on column BADGES.POINT is '獲得ポイント'; +comment on column BADGES.INSERT_USER is '登録ユーザ'; +comment on column BADGES.INSERT_DATETIME is '登録日時'; +comment on column BADGES.UPDATE_USER is '更新ユーザ'; +comment on column BADGES.UPDATE_DATETIME is '更新日時'; +comment on column BADGES.DELETE_FLAG is '削除フラグ'; + +comment on table LIKE_COMMENTS is 'コメントのイイネ'; +comment on column LIKE_COMMENTS.NO is 'NO'; +comment on column LIKE_COMMENTS.COMMENT_NO is 'コメント番号'; +comment on column LIKE_COMMENTS.LIKE_CLASS is '種類'; +comment on column LIKE_COMMENTS.INSERT_USER is '登録ユーザ'; +comment on column LIKE_COMMENTS.INSERT_DATETIME is '登録日時'; +comment on column LIKE_COMMENTS.UPDATE_USER is '更新ユーザ'; +comment on column LIKE_COMMENTS.UPDATE_DATETIME is '更新日時'; +comment on column LIKE_COMMENTS.DELETE_FLAG is '削除フラグ'; + comment on table TOKENS is '認証トークン'; comment on column TOKENS.TOKEN is 'TOKEN'; comment on column TOKENS.USER_ID is 'ユーザID'; @@ -830,7 +1084,7 @@ comment on column SURVEYS.DELETE_FLAG is '削除フラグ'; comment on table EVENTS is 'イベント'; comment on column EVENTS.KNOWLEDGE_ID is 'ナレッジID'; -comment on column EVENTS.START_DATE_TIME is '開催日 UTC'; +comment on column EVENTS.START_DATE_TIME is '開催日 UTC'; comment on column EVENTS.TIME_ZONE is 'タイムゾーン'; comment on column EVENTS.NOTIFY_STATUS is '通知ステータス'; comment on column EVENTS.INSERT_USER is '登録ユーザ'; @@ -931,7 +1185,7 @@ comment on column DRAFT_KNOWLEDGES.DELETE_FLAG is '削除フラグ'; comment on table MAIL_POSTS is 'メールから投稿'; comment on column MAIL_POSTS.MESSAGE_ID is 'Message-ID'; -comment on column MAIL_POSTS.POST_KIND is '投稿区分 1: Knowledge 2:Comment'; +comment on column MAIL_POSTS.POST_KIND is '投稿区分 1: Knowledge 2:Comment'; comment on column MAIL_POSTS.ID is 'ID'; comment on column MAIL_POSTS.SENDER is 'SENDER'; comment on column MAIL_POSTS.INSERT_USER is '登録ユーザ'; @@ -943,10 +1197,10 @@ comment on column MAIL_POSTS.DELETE_FLAG is '削除フラグ'; comment on table MAIL_HOOK_CONDITIONS is 'メールから投稿する条件'; comment on column MAIL_HOOK_CONDITIONS.HOOK_ID is 'HOOK_ID'; comment on column MAIL_HOOK_CONDITIONS.CONDITION_NO is 'CONDITION_NO'; -comment on column MAIL_HOOK_CONDITIONS.CONDITION_KIND is '条件の種類 1:宛先が「条件文字」であった場合'; +comment on column MAIL_HOOK_CONDITIONS.CONDITION_KIND is '条件の種類 1:宛先が「条件文字」であった場合'; comment on column MAIL_HOOK_CONDITIONS.CONDITION is '条件の文字'; comment on column MAIL_HOOK_CONDITIONS.PROCESS_USER is '投稿者'; -comment on column MAIL_HOOK_CONDITIONS.PROCESS_USER_KIND is '投稿者の指定 1:送信者のメールアドレスから、2:常に固定'; +comment on column MAIL_HOOK_CONDITIONS.PROCESS_USER_KIND is '投稿者の指定 1:送信者のメールアドレスから、2:常に固定'; comment on column MAIL_HOOK_CONDITIONS.PUBLIC_FLAG is '公開区分'; comment on column MAIL_HOOK_CONDITIONS.TAGS is 'タグ'; comment on column MAIL_HOOK_CONDITIONS.VIEWERS is '公開先'; @@ -1014,6 +1268,7 @@ comment on column TEMPLATE_MASTERS.TYPE_ID is 'テンプレートの種類ID'; comment on column TEMPLATE_MASTERS.TYPE_NAME is 'テンプレート名'; comment on column TEMPLATE_MASTERS.TYPE_ICON is 'アイコン'; comment on column TEMPLATE_MASTERS.DESCRIPTION is '説明'; +comment on column TEMPLATE_MASTERS.INITIAL_VALUE is '本文の初期値'; comment on column TEMPLATE_MASTERS.INSERT_USER is '登録ユーザ'; comment on column TEMPLATE_MASTERS.INSERT_DATETIME is '登録日時'; comment on column TEMPLATE_MASTERS.UPDATE_USER is '更新ユーザ'; @@ -1026,6 +1281,7 @@ comment on column TEMPLATE_ITEMS.ITEM_NO is '項目NO'; comment on column TEMPLATE_ITEMS.ITEM_NAME is '項目名'; comment on column TEMPLATE_ITEMS.ITEM_TYPE is '項目の種類'; comment on column TEMPLATE_ITEMS.DESCRIPTION is '説明'; +comment on column TEMPLATE_ITEMS.INITIAL_VALUE is '初期値'; comment on column TEMPLATE_ITEMS.INSERT_USER is '登録ユーザ'; comment on column TEMPLATE_ITEMS.INSERT_DATETIME is '登録日時'; comment on column TEMPLATE_ITEMS.UPDATE_USER is '更新ユーザ'; @@ -1111,6 +1367,7 @@ comment on column ACCOUNT_IMAGES.DELETE_FLAG is '削除フラグ'; comment on table LIKES is 'いいね'; comment on column LIKES.NO is 'NO'; comment on column LIKES.KNOWLEDGE_ID is 'ナレッジID'; +comment on column LIKES.LIKE_CLASS is '種類'; comment on column LIKES.INSERT_USER is '登録ユーザ'; comment on column LIKES.INSERT_DATETIME is '登録日時'; comment on column LIKES.UPDATE_USER is '更新ユーザ'; @@ -1218,8 +1475,10 @@ comment on column KNOWLEDGES.TAG_IDS is 'タグID一覧'; comment on column KNOWLEDGES.TAG_NAMES is 'タグ名称一覧'; comment on column KNOWLEDGES.LIKE_COUNT is 'いいね件数'; comment on column KNOWLEDGES.COMMENT_COUNT is 'コメント件数'; +comment on column KNOWLEDGES.VIEW_COUNT is '参照件数'; comment on column KNOWLEDGES.TYPE_ID is 'テンプレートの種類ID'; comment on column KNOWLEDGES.NOTIFY_STATUS is '通知ステータス'; +comment on column KNOWLEDGES.POINT is 'ポイント'; comment on column KNOWLEDGES.INSERT_USER is '登録ユーザ'; comment on column KNOWLEDGES.INSERT_DATETIME is '登録日時'; comment on column KNOWLEDGES.UPDATE_USER is '更新ユーザ'; diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_0.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_0.sql new file mode 100644 index 000000000..ec7c35aba --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_0.sql @@ -0,0 +1,19 @@ +ALTER TABLE KNOWLEDGES DROP COLUMN IF EXISTS VIEW_COUNT; +ALTER TABLE KNOWLEDGES ADD COLUMN VIEW_COUNT bigint; + +comment on column KNOWLEDGES.VIEW_COUNT is '参照件数'; + +drop index if exists IDX_VIEW_HISTORIES_INSERT_USER; +create index IDX_VIEW_HISTORIES_INSERT_USER + on VIEW_HISTORIES(INSERT_USER); + +drop index if exists IDX_VIEW_HISTORIES_KNOWLEDGE_ID_INSERT_USER; +create index IDX_VIEW_HISTORIES_KNOWLEDGE_ID_INSERT_USER + on VIEW_HISTORIES(KNOWLEDGE_ID,INSERT_USER); + +UPDATE KNOWLEDGES + SET VIEW_COUNT = ( + SELECT COUNT(*) FROM VIEW_HISTORIES + WHERE VIEW_HISTORIES.KNOWLEDGE_ID = KNOWLEDGES.KNOWLEDGE_ID + GROUP BY VIEW_HISTORIES.KNOWLEDGE_ID + ); diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_1.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_1.sql new file mode 100644 index 000000000..cf648aa53 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_1.sql @@ -0,0 +1,88 @@ +-- コメントのイイネ +drop table if exists LIKE_COMMENTS cascade; + +create table LIKE_COMMENTS ( + NO BIGSERIAL not null + , COMMENT_NO bigint not null + , LIKE_CLASS integer default 1 + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint LIKE_COMMENTS_PKC primary key (NO) +) ; + +create index IDX_LIKE_COMMENTS_COMMENT_NO + on LIKE_COMMENTS(COMMENT_NO); + +comment on table LIKE_COMMENTS is 'コメントのイイネ'; +comment on column LIKE_COMMENTS.NO is 'NO'; +comment on column LIKE_COMMENTS.COMMENT_NO is 'コメント番号'; +comment on column LIKE_COMMENTS.LIKE_CLASS is '種類'; +comment on column LIKE_COMMENTS.INSERT_USER is '登録ユーザ'; +comment on column LIKE_COMMENTS.INSERT_DATETIME is '登録日時'; +comment on column LIKE_COMMENTS.UPDATE_USER is '更新ユーザ'; +comment on column LIKE_COMMENTS.UPDATE_DATETIME is '更新日時'; +comment on column LIKE_COMMENTS.DELETE_FLAG is '削除フラグ'; + +ALTER TABLE LIKES DROP COLUMN IF EXISTS LIKE_CLASS; +ALTER TABLE LIKES ADD COLUMN LIKE_CLASS integer default 1; + +comment on column LIKES.LIKE_CLASS is '種類'; + +-- ユーザへの通知 +drop table if exists USER_NOTIFICATIONS cascade; + +create table USER_NOTIFICATIONS ( + USER_ID INTEGER not null + , NO bigint not null + , STATUS integer + , ROW_ID character varying(64) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint USER_NOTIFICATIONS_PKC primary key (USER_ID,NO) +) ; + +-- 通知 +drop table if exists NOTIFICATIONS cascade; + +create table NOTIFICATIONS ( + NO BIGSERIAL not null + , TITLE VARCHAR(256) + , CONTENT text + , ROW_ID character varying(64) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint NOTIFICATIONS_PKC primary key (NO) +) ; + + +comment on table USER_NOTIFICATIONS is 'ユーザへの通知'; +comment on column USER_NOTIFICATIONS.USER_ID is 'ユーザID'; +comment on column USER_NOTIFICATIONS.NO is 'NO'; +comment on column USER_NOTIFICATIONS.STATUS is 'ステータス'; +comment on column USER_NOTIFICATIONS.ROW_ID is '行ID'; +comment on column USER_NOTIFICATIONS.INSERT_USER is '登録ユーザ'; +comment on column USER_NOTIFICATIONS.INSERT_DATETIME is '登録日時'; +comment on column USER_NOTIFICATIONS.UPDATE_USER is '更新ユーザ'; +comment on column USER_NOTIFICATIONS.UPDATE_DATETIME is '更新日時'; +comment on column USER_NOTIFICATIONS.DELETE_FLAG is '削除フラグ'; + +comment on table NOTIFICATIONS is '通知'; +comment on column NOTIFICATIONS.NO is 'NO'; +comment on column NOTIFICATIONS.TITLE is 'タイトル'; +comment on column NOTIFICATIONS.CONTENT is 'メッセージ'; +comment on column NOTIFICATIONS.ROW_ID is '行ID'; +comment on column NOTIFICATIONS.INSERT_USER is '登録ユーザ'; +comment on column NOTIFICATIONS.INSERT_DATETIME is '登録日時'; +comment on column NOTIFICATIONS.UPDATE_USER is '更新ユーザ'; +comment on column NOTIFICATIONS.UPDATE_DATETIME is '更新日時'; +comment on column NOTIFICATIONS.DELETE_FLAG is '削除フラグ'; + diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_2.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_2.sql new file mode 100644 index 000000000..0af68a392 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_2.sql @@ -0,0 +1,165 @@ +-- ユーザのポイント獲得履歴 +drop table if exists POINT_USER_HISTORIES cascade; + +create table POINT_USER_HISTORIES ( + USER_ID INTEGER not null + , HISTORY_NO BIGINT not null + , ACTIVITY_NO BIGINT not null + , TYPE integer not null + , POINT integer not null + , BEFORE_TOTAL integer not null + , TOTAL integer not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint POINT_USER_HISTORIES_PKC primary key (USER_ID,HISTORY_NO) +) ; + +create index IDX_POINT_USER_HISTORIES_INSERT_DATETIME + on POINT_USER_HISTORIES(INSERT_DATETIME); + +-- ナレッジのポイント獲得履歴 +drop table if exists POINT_KNOWLEDGE_HISTORIES cascade; + +create table POINT_KNOWLEDGE_HISTORIES ( + KNOWLEDGE_ID BIGINT not null + , HISTORY_NO BIGINT not null + , ACTIVITY_NO BIGINT not null + , TYPE integer not null + , POINT integer not null + , BEFORE_TOTAL integer not null + , TOTAL integer not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint POINT_KNOWLEDGE_HISTORIES_PKC primary key (KNOWLEDGE_ID,HISTORY_NO) +) ; + +create index IDX_POINT_KNOWLEDGE_HISTORIES_INSERT_DATETIME + on POINT_KNOWLEDGE_HISTORIES(INSERT_DATETIME); + +-- ユーザの称号 +drop table if exists USER_BADGES cascade; + +create table USER_BADGES ( + USER_ID INTEGER not null + , NO INTEGER not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint USER_BADGES_PKC primary key (USER_ID,NO) +) ; + +-- アクティビティ +drop table if exists ACTIVITIES cascade; + +create table ACTIVITIES ( + ACTIVITY_NO BIGSERIAL not null + , USER_ID INTEGER not null + , KIND integer not null + , TARGET character varying(64) not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint ACTIVITIES_PKC primary key (ACTIVITY_NO) +) ; + +create index IDX_ACTIVITIES_USER_ID + on ACTIVITIES(USER_ID); + +create index IDX_ACTIVITIES_KIND_TARGET + on ACTIVITIES(KIND,TARGET); + +-- 称号 +drop table if exists BADGES cascade; + +create table BADGES ( + NO SERIAL not null + , NAME character varying(128) not null + , DISPLAY_TEXT character varying(32) not null + , DESCRIPTION text + , IMAGE character varying(64) + , POINT integer + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint BADGES_PKC primary key (NO) +) ; + + +comment on table POINT_USER_HISTORIES is 'ユーザのポイント獲得履歴'; +comment on column POINT_USER_HISTORIES.USER_ID is 'ユーザID'; +comment on column POINT_USER_HISTORIES.HISTORY_NO is '履歴番号'; +comment on column POINT_USER_HISTORIES.ACTIVITY_NO is 'アクティビティ番号'; +comment on column POINT_USER_HISTORIES.TYPE is '獲得のタイプ'; +comment on column POINT_USER_HISTORIES.POINT is '獲得ポイント'; +comment on column POINT_USER_HISTORIES.BEFORE_TOTAL is '獲得前ポイント'; +comment on column POINT_USER_HISTORIES.TOTAL is 'トータルポイント'; +comment on column POINT_USER_HISTORIES.INSERT_USER is '登録ユーザ'; +comment on column POINT_USER_HISTORIES.INSERT_DATETIME is '登録日時'; +comment on column POINT_USER_HISTORIES.UPDATE_USER is '更新ユーザ'; +comment on column POINT_USER_HISTORIES.UPDATE_DATETIME is '更新日時'; +comment on column POINT_USER_HISTORIES.DELETE_FLAG is '削除フラグ'; + +comment on table POINT_KNOWLEDGE_HISTORIES is 'ナレッジのポイント獲得履歴'; +comment on column POINT_KNOWLEDGE_HISTORIES.KNOWLEDGE_ID is 'ナレッジID'; +comment on column POINT_KNOWLEDGE_HISTORIES.HISTORY_NO is '履歴番号'; +comment on column POINT_KNOWLEDGE_HISTORIES.ACTIVITY_NO is 'アクティビティ番号'; +comment on column POINT_KNOWLEDGE_HISTORIES.TYPE is '獲得のタイプ'; +comment on column POINT_KNOWLEDGE_HISTORIES.POINT is '獲得ポイント'; +comment on column POINT_KNOWLEDGE_HISTORIES.BEFORE_TOTAL is '獲得前ポイント'; +comment on column POINT_KNOWLEDGE_HISTORIES.TOTAL is 'トータルポイント'; +comment on column POINT_KNOWLEDGE_HISTORIES.INSERT_USER is '登録ユーザ'; +comment on column POINT_KNOWLEDGE_HISTORIES.INSERT_DATETIME is '登録日時'; +comment on column POINT_KNOWLEDGE_HISTORIES.UPDATE_USER is '更新ユーザ'; +comment on column POINT_KNOWLEDGE_HISTORIES.UPDATE_DATETIME is '更新日時'; +comment on column POINT_KNOWLEDGE_HISTORIES.DELETE_FLAG is '削除フラグ'; + +comment on table USER_BADGES is 'ユーザの称号'; +comment on column USER_BADGES.USER_ID is 'ユーザID'; +comment on column USER_BADGES.NO is '番号'; +comment on column USER_BADGES.INSERT_USER is '登録ユーザ'; +comment on column USER_BADGES.INSERT_DATETIME is '登録日時'; +comment on column USER_BADGES.UPDATE_USER is '更新ユーザ'; +comment on column USER_BADGES.UPDATE_DATETIME is '更新日時'; +comment on column USER_BADGES.DELETE_FLAG is '削除フラグ'; + +comment on table ACTIVITIES is 'アクティビティ'; +comment on column ACTIVITIES.ACTIVITY_NO is 'アクティビティ番号'; +comment on column ACTIVITIES.USER_ID is 'イベントをおこしたユーザ'; +comment on column ACTIVITIES.KIND is 'アクティビティの種類'; +comment on column ACTIVITIES.TARGET is 'ターゲットID'; +comment on column ACTIVITIES.INSERT_USER is '登録ユーザ'; +comment on column ACTIVITIES.INSERT_DATETIME is '登録日時'; +comment on column ACTIVITIES.UPDATE_USER is '更新ユーザ'; +comment on column ACTIVITIES.UPDATE_DATETIME is '更新日時'; +comment on column ACTIVITIES.DELETE_FLAG is '削除フラグ'; + +comment on table BADGES is '称号'; +comment on column BADGES.NO is '番号'; +comment on column BADGES.NAME is '名称'; +comment on column BADGES.DISPLAY_TEXT is '表示名'; +comment on column BADGES.DESCRIPTION is '説明'; +comment on column BADGES.IMAGE is '画像'; +comment on column BADGES.POINT is '獲得ポイント'; +comment on column BADGES.INSERT_USER is '登録ユーザ'; +comment on column BADGES.INSERT_DATETIME is '登録日時'; +comment on column BADGES.UPDATE_USER is '更新ユーザ'; +comment on column BADGES.UPDATE_DATETIME is '更新日時'; +comment on column BADGES.DELETE_FLAG is '削除フラグ'; + + +ALTER TABLE KNOWLEDGES DROP COLUMN IF EXISTS POINT; +ALTER TABLE KNOWLEDGES ADD COLUMN POINT integer default 0 not null; +comment on column KNOWLEDGES.POINT is 'ポイント'; + diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_3.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_3.sql new file mode 100644 index 000000000..f8fc68aab --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_3.sql @@ -0,0 +1,11 @@ +ALTER TABLE TEMPLATE_MASTERS DROP COLUMN IF EXISTS INITIAL_VALUE; +ALTER TABLE TEMPLATE_MASTERS ADD COLUMN INITIAL_VALUE text; + +comment on column TEMPLATE_MASTERS.INITIAL_VALUE is '本文の初期値'; + +ALTER TABLE TEMPLATE_ITEMS DROP COLUMN IF EXISTS INITIAL_VALUE; +ALTER TABLE TEMPLATE_ITEMS ADD COLUMN INITIAL_VALUE text; + +comment on column TEMPLATE_ITEMS.INITIAL_VALUE is '初期値'; + + diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_4.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_4.sql new file mode 100644 index 000000000..485dcaae0 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_11_0/migrate_v1_11_4.sql @@ -0,0 +1,56 @@ +-- いいねの通知状態 +drop table if exists NOTIFICATION_STATUS cascade; + +create table NOTIFICATION_STATUS ( + TYPE integer not null + , TARGET_ID bigint not null + , USER_ID integer not null + , STATUS integer + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint NOTIFICATION_STATUS_PKC primary key (TYPE,TARGET_ID,USER_ID) +) ; + +-- メールから投稿の際の除外条件 +drop table if exists MAIL_HOOK_IGNORE_CONDITIONS cascade; + +create table MAIL_HOOK_IGNORE_CONDITIONS ( + HOOK_ID INTEGER not null + , CONDITION_NO integer not null + , IGNORE_CONDITION_NO integer not null + , CONDITION_KIND integer not null + , CONDITION character varying(256) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint MAIL_HOOK_IGNORE_CONDITIONS_PKC primary key (HOOK_ID,CONDITION_NO,IGNORE_CONDITION_NO) +) ; + +comment on table NOTIFICATION_STATUS is 'いいねの通知状態'; +comment on column NOTIFICATION_STATUS.TYPE is '種類'; +comment on column NOTIFICATION_STATUS.TARGET_ID is 'ターゲットのID'; +comment on column NOTIFICATION_STATUS.USER_ID is '登録者'; +comment on column NOTIFICATION_STATUS.STATUS is '通知の状態'; +comment on column NOTIFICATION_STATUS.INSERT_USER is '登録ユーザ'; +comment on column NOTIFICATION_STATUS.INSERT_DATETIME is '登録日時'; +comment on column NOTIFICATION_STATUS.UPDATE_USER is '更新ユーザ'; +comment on column NOTIFICATION_STATUS.UPDATE_DATETIME is '更新日時'; +comment on column NOTIFICATION_STATUS.DELETE_FLAG is '削除フラグ'; + +comment on table MAIL_HOOK_IGNORE_CONDITIONS is 'メールから投稿の際の除外条件'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.HOOK_ID is 'HOOK_ID'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.CONDITION_NO is 'CONDITION_NO'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.IGNORE_CONDITION_NO is 'IGNORE_CONDITION_NO'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.CONDITION_KIND is '条件の種類 1:宛先が「条件文字」であった場合'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.CONDITION is '条件の文字'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.INSERT_USER is '登録ユーザ'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.INSERT_DATETIME is '登録日時'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.UPDATE_USER is '更新ユーザ'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.UPDATE_DATETIME is '更新日時'; +comment on column MAIL_HOOK_IGNORE_CONDITIONS.DELETE_FLAG is '削除フラグ'; + diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_add_participate.xml b/src/main/resources/org/support/project/knowledge/mail/notify_add_participate.xml index abc7348f2..4f23da0f7 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_add_participate.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_add_participate.xml @@ -15,7 +15,7 @@ Add a participant for your event. Please understand that it can not reply to this email. -Add Participant +Add a Participant Service send a notice on add a participant for event. diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_add_participate_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_add_participate_ja.xml index 46d9c48fd..cd8b93e51 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_add_participate_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_add_participate_ja.xml @@ -15,7 +15,7 @@ このメールに対する返信は出来ませんので御了承ください。 -参加者登録 +参加登録の通知 参加者が登録された場合に、開催者(=登録者)に通知をだします。 diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment.xml index 512d493bf..0c0789c29 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment.xml @@ -7,13 +7,14 @@ Comment was added:{KnowledgeId} {URL} ------------------------------------------ -{CommentInsertUser} +User: {CommentInsertUser} -{CommentContents} +Comment: {CommentContents} ------------------------------------------ -{KnowledgeTitle} +Title: {KnowledgeTitle} +------------------------------------------ {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_ja.xml index 87b489bb0..52015a1f6 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_ja.xml @@ -7,13 +7,14 @@ {URL} ------------------------------------------ -{CommentInsertUser} +User: {CommentInsertUser} -{CommentContents} +Comment: {CommentContents} ------------------------------------------ -{KnowledgeTitle} +Title: {KnowledgeTitle} +------------------------------------------ {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem.xml index c6221b87a..9935d955b 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem.xml @@ -7,16 +7,18 @@ Comment has been registered to your registered knowledge:{KnowledgeId} {URL} ------------------------------------------ -{CommentInsertUser} +User: {CommentInsertUser} -{CommentContents} +Comment: {CommentContents} ------------------------------------------ -{KnowledgeTitle} +Title: {KnowledgeTitle} +------------------------------------------ {Contents} ------------------------------------------ + This e-mail has been sent automatically from the system. Please understand that it can not reply to this email. diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem_ja.xml index 706fc9192..e6a6dabfd 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_comment_myitem_ja.xml @@ -7,13 +7,14 @@ {URL} ------------------------------------------ -{CommentInsertUser} +User: {CommentInsertUser} -{CommentContents} +Comment: {CommentContents} ------------------------------------------ -{KnowledgeTitle} +Title: {KnowledgeTitle} +------------------------------------------ {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml index 68217d433..c6c8622d7 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_knowledge.xml @@ -11,7 +11,6 @@ User: {User} Title: {KnowledgeTitle} ------------------------------------------ - {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem.xml index 69a0cb09d..adf3fe976 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem.xml @@ -7,8 +7,9 @@ {URL} ------------------------------------------ -{KnowledgeTitle} +Title: {KnowledgeTitle} +------------------------------------------ {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem_ja.xml index 4a5d7d0b9..def1ba614 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_insert_like_myitem_ja.xml @@ -2,13 +2,14 @@ [Knowledge] 評価の通知 {KnowledgeId} - {KnowledgeTitle} -以下のナレッジに「いいね!」が押されました! +あなたの投稿に、「いいね!」が登録されました。 {URL} ------------------------------------------ -{KnowledgeTitle} +Title: {KnowledgeTitle} +------------------------------------------ {Contents} ------------------------------------------ diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_registration_event.xml b/src/main/resources/org/support/project/knowledge/mail/notify_registration_event.xml index 711de8264..66af5dfcf 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_registration_event.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_registration_event.xml @@ -16,7 +16,7 @@ Status: {Status} Please understand that it can not reply to this email. -Registration to event +Registration to the event System will notify the user who registered for participation. diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_registration_event_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_registration_event_ja.xml index 257662c89..e97e429ac 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_registration_event_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_registration_event_ja.xml @@ -16,7 +16,7 @@ Status: {Status} このメールに対する返信は出来ませんので御了承ください。 -参加者登録 +イベントへの参加を登録しました 参加登録したユーザに通知を出します。 diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate.xml b/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate.xml index 6302d8099..fb8365356 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate.xml @@ -15,7 +15,7 @@ Remove a participant for your event. Please understand that it can not reply to this email. -Add Participant +Remove a participant Service send a notice on remove a participant for event. diff --git a/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate_ja.xml b/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate_ja.xml index de1fe65d4..2eea0ecdd 100644 --- a/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate_ja.xml +++ b/src/main/resources/org/support/project/knowledge/mail/notify_remove_participate_ja.xml @@ -15,7 +15,7 @@ このメールに対する返信は出来ませんので御了承ください。 -参加者登録 +参加取り消しの通知 参加者が参加取り消しを実施した場合に、開催者(=登録者)に通知をだします。 diff --git a/src/main/webapp/WEB-INF/views/admin/aggregate/index.jsp b/src/main/webapp/WEB-INF/views/admin/aggregate/index.jsp new file mode 100644 index 000000000..bc394838e --- /dev/null +++ b/src/main/webapp/WEB-INF/views/admin/aggregate/index.jsp @@ -0,0 +1,83 @@ +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% JspUtil jspUtil = new JspUtil(request, pageContext); %> + + + + + + + + + + + + + + + + + + + + +

+<%= jspUtil.label("knowledge.aggregate.title") %> +

+<%= jspUtil.label("knowledge.aggregate.msg") %> +
+
+
+ +-- Execute Log--
+ + +<%= jspUtil.label("knowledge.admin.backtomenu") %> + +
+ +
+ diff --git a/src/main/webapp/WEB-INF/views/admin/config/system.jsp b/src/main/webapp/WEB-INF/views/admin/config/system.jsp index 86e0895f4..3a2b87728 100644 --- a/src/main/webapp/WEB-INF/views/admin/config/system.jsp +++ b/src/main/webapp/WEB-INF/views/admin/config/system.jsp @@ -38,11 +38,11 @@
-
+

+
+
+ +
+ +
+ +
+Application version: <%= jspUtil.label("label.version") %>
+Database schema version: <%= jspUtil.out("db_version") %>
diff --git a/src/main/webapp/WEB-INF/views/admin/database/connection.jsp b/src/main/webapp/WEB-INF/views/admin/database/connection.jsp index b9168ae8f..4cd27e3df 100644 --- a/src/main/webapp/WEB-INF/views/admin/database/connection.jsp +++ b/src/main/webapp/WEB-INF/views/admin/database/connection.jsp @@ -127,7 +127,11 @@
- + <%=jspUtil.label("knowledge.connection.label.URL")%> + (<%=jspUtil.label("knowledge.connection.msg.info.url")%>) + + " value="<%=jspUtil.out("uRL")%>" />
diff --git a/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp b/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp index b42b95965..294813e72 100644 --- a/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp +++ b/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp @@ -102,6 +102,9 @@
  •  <%=jspUtil.label("knowledge.navbar.data.reindexing")%>
  • +
  • +  <%=jspUtil.label("knowledge.aggregate.title")%> +
  •  <%=jspUtil.label("knowledge.navbar.data.export")%>
  • diff --git a/src/main/webapp/WEB-INF/views/admin/template/edit.jsp b/src/main/webapp/WEB-INF/views/admin/template/edit.jsp index b4b6bc6c4..1973ea1e9 100644 --- a/src/main/webapp/WEB-INF/views/admin/template/edit.jsp +++ b/src/main/webapp/WEB-INF/views/admin/template/edit.jsp @@ -48,6 +48,10 @@
    +
    + + +
    <%= jspUtil.label("knowledge.template.label.item") %>
    diff --git a/src/main/webapp/WEB-INF/views/admin/webhook/config.jsp b/src/main/webapp/WEB-INF/views/admin/webhook/config.jsp index 336378d81..8d7fb913a 100644 --- a/src/main/webapp/WEB-INF/views/admin/webhook/config.jsp +++ b/src/main/webapp/WEB-INF/views/admin/webhook/config.jsp @@ -60,14 +60,14 @@ function testConfig(hookId) {
    - +

    <%= jspUtil.label("knowledge.webhook.event.knowledge.description") %>

    - +

    <%= jspUtil.label("knowledge.webhook.event.comment.description") %>

    diff --git a/src/main/webapp/WEB-INF/views/auth/form.jsp b/src/main/webapp/WEB-INF/views/auth/form.jsp index c7f5a2a36..57dfc4974 100644 --- a/src/main/webapp/WEB-INF/views/auth/form.jsp +++ b/src/main/webapp/WEB-INF/views/auth/form.jsp @@ -19,73 +19,74 @@

    <%= jspUtil.label("label.login") %>

    -
    -
    - - <% if (!StringUtils.isEmpty(request.getAttribute("page")) - && !"/open.knowledge/list".equals(request.getAttribute("page"))) { %> -
    -
    - <%= jspUtil.label("knowledge.auth.description") %> -
    -
    - <% } %> - - -
    -
    - -
    -
    -
    - -
    - -
    - " - placeholder="<%= jspUtil.label("knowledge.auth.label.id") %>" autofocus> -
    -
    -
    - -
    - " - placeholder="<%= jspUtil.label("knowledge.auth.label.password") %>"> -
    -
    - " id="page"> - - -  <%= jspUtil.label("knowledge.auth.forgot.password") %> - -

    - -
    -
    - +
    + + + <% if (!StringUtils.isEmpty(request.getAttribute("page")) + && !"/open.knowledge/list".equals(request.getAttribute("page"))) { %> +
    +
    + <%= jspUtil.label("knowledge.auth.description") %> +
    +
    + <% } %> + + +
    +
    + +
    +
    +
    + +
    + +
    + " + placeholder="<%= jspUtil.label("knowledge.auth.label.id") %>" autofocus> +
    +
    +
    + +
    + " + placeholder="<%= jspUtil.label("knowledge.auth.label.password") %>"> +
    +
    + " id="page"> + +
    +
    + <% if (SystemConfigLogic.get().isUserAddAble()) { %> - -  <%= jspUtil.label("knowledge.auth.signup") %> - + +  <%= jspUtil.label("knowledge.auth.signup") %> + <% } %> -
    -
    - - - +

    + +  <%= jspUtil.label("knowledge.auth.forgot.password") %> + -
    - + +
    +
    + + + + +
    +
    diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp index c216f94a9..e3c6c2d85 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp @@ -37,8 +37,10 @@ <% if (StringUtils.isNotEmpty(jspUtil.out("thema"))) { %> /bootstrap.min.css" /> +.css" /> <% } else { %> /bootstrap.min.css" /> +.css" /> <% } %> <% if (StringUtils.isNotEmpty(jspUtil.out("highlight"))) { %> diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp index 4895daee3..f627b1087 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp @@ -1,3 +1,4 @@ +<%@page import="org.support.project.knowledge.control.Control"%> <%@page import="org.support.project.knowledge.entity.ServiceConfigsEntity"%> <%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> @@ -66,10 +67,10 @@