.
This commit is contained in:
commit
03d1baaac7
117 files changed
+8048
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
target
|
||||
classes
|
||||
.idea
|
||||
@@ -0,0 +1,83 @@
|
||||
アトリビューション—シェアアライク 2.1
|
||||
(帰属—同一条件許諾)
|
||||
クリエイティブ・コモンズ及びクリエイティブ・コモンズ・ジャパンは法律事務所ではありません。この利用許諾条項の頒布は法的アドバイスその他の法律業務を行うものではありません。クリエイティブ・コモンズ及びクリエイティブ・コモンズ・ジャパンは、この利用許諾の当事者ではなく、ここに提供する情報及び本作品に関しいかなる保証も行いません。クリエイティブ・コモンズ及びクリエイティブ・コモンズ・ジャパンは、いかなる法令に基づこうとも、あなた又はいかなる第三者の損害(この利用許諾に関連する通常損害、特別損害を含みますがこれらに限られません)について責任を負いません。
|
||||
|
||||
利用許諾
|
||||
|
||||
本作品(下記に定義する)は、このクリエイティブ・コモンズ・パブリック・ライセンス日本版(以下「この利用許諾」という)の条項の下で提供される。本作品は、著作権法及び/又は他の適用法によって保護される。本作品をこの利用許諾又は著作権法の下で授権された以外の方法で使用することを禁止する。
|
||||
|
||||
許諾者は、かかる条項をあなたが承諾することとひきかえに、ここに規定される権利をあなたに付与する。本作品に関し、この利用許諾の下で認められるいずれかの利用を行うことにより、あなたは、この利用許諾(条項)に拘束されることを承諾し同意したこととなる。
|
||||
|
||||
第1条 定義
|
||||
|
||||
この利用許諾中の用語を以下のように定義する。その他の用語は、著作権法その他の法令で定める意味を持つものとする。
|
||||
|
||||
a. 「二次的著作物」とは、著作物を翻訳し、編曲し、若しくは変形し、または脚色し、映画化し、その他翻案することにより創作した著作物をいう。ただし、編集著作物又はデータベースの著作物(以下、この二つを併せて「編集著作物等」という。)を構成する著作物は、二次的著作物とみなされない。また、原著作者及び実演家の名誉又は声望を害する方法で原著作物を改作、変形もしくは翻案して生じる著作物は、この利用許諾の目的においては、二次的著作物に含まれない。
|
||||
b. 「許諾者」とは、この利用許諾の条項の下で本作品を提供する個人又は団体をいう。
|
||||
c. 「あなた」とは、この利用許諾に基づく権利を行使する個人又は団体をいう。
|
||||
d. 「原著作者」とは、本作品に含まれる著作物を創作した個人又は団体をいう。
|
||||
e. 「本作品」とは、この利用許諾の条項に基づいて利用する権利が付与される対象たる無体物をいい、著作物、実演、レコード、放送にかかる音又は影像、もしくは有線放送にかかる音又は影像をすべて含むものとする。
|
||||
f. 「ライセンス要素」とは、許諾者が選択し、この利用許諾に表示されている、以下のライセンス属性をいう:帰属・同一条件許諾
|
||||
|
||||
第2条 著作権等に対する制限
|
||||
|
||||
この利用許諾に含まれるいかなる条項によっても、許諾者は、あなたが著作権の制限(著作権法第30条〜49条)、著作者人格権に対する制限(著作権法第18条2項〜4項、第19条2項〜4項、第20条2項)、著作隣接権に対する制限(著作権法第102条)その他、著作権法又はその他の適用法に基づいて認められることとなる本作品の利用を禁止しない。
|
||||
|
||||
第3条 ライセンスの付与
|
||||
|
||||
この利用許諾の条項に従い、許諾者はあなたに、本作品に関し、すべての国で、ロイヤリティ・フリー、非排他的で、(第7条bに定める期間)継続的な以下のライセンスを付与する。ただし、あなたが以前に本作品に関するこの利用許諾の条項に違反したことがないか、あるいは、以前にこの利用許諾の条項に違反したがこの利用許諾に基づく権利を行使するために許諾者から明示的な許可を得ている場合に限る。
|
||||
|
||||
a. 本作品に含まれる著作物(以下「本著作物」という。)を複製すること(編集著作物等に組み込み複製することを含む。以下、同じ。)、
|
||||
b. 本著作物を翻案して二次的著作物を創作し、複製すること、
|
||||
c. 本著作物又はその二次的著作物の複製物を頒布すること(譲渡または貸与により公衆に提供することを含む。以下同じ。)、上演すること、演奏すること、上映すること、公衆送信を行うこと(送信可能化を含む。以下、同じ。)、公に口述すること、公に展示すること、
|
||||
d. 本作品に含まれる実演を、録音・録画すること(録音・録画物を増製することを含む)、録音・録画物により頒布すること、公衆送信を行うこと、
|
||||
e. 本作品に含まれるレコードを、複製すること、頒布すること、公衆送信を行うこと、
|
||||
f. 本作品に含まれる、放送に係る音又は影像を、複製すること、その放送を受信して再放送すること又は有線放送すること、その放送又はこれを受信して行う有線放送を受信して送信可能化すること、そのテレビジョン放送又はこれを受信して行う有線放送を受信して、影像を拡大する特別の装置を用いて公に伝達すること、
|
||||
g. 本作品に含まれる、有線放送に係る音又は影像を、複製すること、その有線放送を受信して放送し、又は再有線放送すること、その有線放送を受信して送信可能化すること、その有線テレビジョン放送を受信して、影像を拡大する特別の装置を用いて公に伝達すること、
|
||||
|
||||
上記に定められた本作品又はその二次的著作物の利用は、現在及び将来のすべての媒体・形式で行うことができる。あなたは、他の媒体及び形式で本作品又はその二次的著作物を利用するのに技術的に必要な変更を行うことができる。許諾者は本作品又はその二次的著作物に関して、この利用許諾に従った利用については自己が有する著作者人格権及び実演家人格権を行使しない。許諾者によって明示的に付与されない全ての権利は、留保される。
|
||||
|
||||
第4条 受領者へのライセンス提供
|
||||
|
||||
あなたが本作品をこの利用許諾に基づいて利用する度毎に、許諾者は本作品又は本作品の二次的著作物の受領者に対して、直接、この利用許諾の下であなたに許可された利用許諾と同じ条件の本作品のライセンスを提供する。
|
||||
|
||||
第5条 制限
|
||||
|
||||
上記第3条及び第4条により付与されたライセンスは、以下の制限に明示的に従い、制約される。
|
||||
|
||||
a. あなたは、この利用許諾の条項に基づいてのみ、本作品を利用することができる。
|
||||
b. あなたは、この利用許諾又はこの利用許諾と同一のライセンス要素を含むほかのクリエイティブ・コモンズ・ライセンス(例えば、この利用許諾の新しいバージョン、又はこの利用許諾と同一のライセンス要素の他国籍ライセンスなど)に基づいてのみ、本作品の二次的著作物を利用することができる。
|
||||
c. あなたは、本作品を利用するときは、この利用許諾の写し又はURI(Uniform Resource Identifier)を本作品の複製物に添付又は表示しなければならない。
|
||||
d. あなたは、本作品の二次的著作物を利用するときは、この利用許諾又はこの利用許諾と同一のライセンス要素を含むほかのクリエイティブ・コモンズ・ライセンスの写し又はURIを本作品の二次的著作物の複製物に添付または表示しなければならない。
|
||||
e. あなたは、この利用許諾条項及びこの利用許諾によって付与される利用許諾受領者の権利の行使を変更又は制限するような、本作品又はその二次的著作物に係る条件を提案したり課したりしてはならない。
|
||||
f. あなたは、本作品を再利用許諾することができない。
|
||||
g. あなたは、本作品又はその二次的著作物の利用にあたって、この利用許諾及びその免責条項に関する注意書きの内容を変更せず、見やすい態様でそのまま掲載しなければならない。
|
||||
h. あなたは、この利用許諾条項と矛盾する方法で本著作物へのアクセス又は使用をコントロールするような技術的保護手段を用いて、本作品又はその二次的著作物を利用してはならない。
|
||||
i. 本条の制限は、本作品又はその二次的著作物が編集著作物等に組み込まれた場合にも、その組み込まれた作品に関しては適用される。しかし、本作品又はその二次的著作物が組み込まれた編集著作物等そのものは、この利用許諾の条項に従う必要はない。
|
||||
j. あなたは、本作品、その二次的著作物又は本作品を組み込んだ編集著作物等を利用する場合には、(1)本作品に係るすべての著作権表示をそのままにしておかなければならず、(2)原著作者及び実演家のクレジットを、合理的な方式で、(もし示されていれば原著作者及び実演家の名前又は変名を伝えることにより、)表示しなければならず、(3)本作品のタイトルが示されている場合には、そのタイトルを表示しなければならず、(4)許諾者が本作品に添付するよう指定したURIがあれば、合理的に実行可能な範囲で、そのURIを表示しなければならず(ただし、そのURIが本作品の著作権表示またはライセンス情報を参照するものでないときはこの限りでない。)(5)二次的著作物の場合には、当該二次的著作物中の原著作物の利用を示すクレジットを表示しなければならない。これらのクレジットは、合理的であればどんな方法でも行うことができる。しかしながら、二次的著作物又は編集著作物等の場合には、少なくとも他の同様の著作者のクレジットが表示される箇所で当該クレジットを表示し、少なくとも他の同様の著作者のクレジットと同程度に目立つ方法であることを要する。
|
||||
k. もし、あなたが、本作品の二次的著作物、又は本作品もしくはその二次的著作物を組み込んだ編集著作物等を創作した場合、あなたは、許諾者からの通知があれば、実行可能な範囲で、要求に応じて、二次的著作物又は編集著作物等から、許諾者又は原著作者への言及をすべて除去しなければならない。
|
||||
|
||||
第6条 責任制限
|
||||
|
||||
この利用許諾の両当事者が書面にて別途合意しない限り、許諾者は本作品を現状のまま提供するものとし、明示・黙示を問わず、本作品に関していかなる保証(特定の利用目的への適合性、第三者の権利の非侵害、欠陥の不存在を含むが、これに限られない。)もしない。
|
||||
|
||||
この利用許諾又はこの利用許諾に基づく本作品の利用から発生する、いかなる損害(許諾者が、本作品にかかる著作権、著作隣接権、著作者人格権、実演家人格権、商標権、パブリシティ権、不正競争防止法その他関連法規上保護される利益を有する者からの許諾を得ることなく本作品の利用許諾を行ったことにより発生する損害、プライバシー侵害又は名誉毀損から発生する損害等の通常損害、及び特別損害を含むが、これに限らない。)についても、許諾者に故意又は重大な過失がある場合を除き、許諾者がそのような損害発生の可能性を知らされたか否かを問わず、許諾者は、あなたに対し、これを賠償する責任を負わない。
|
||||
|
||||
第7条 終了
|
||||
|
||||
a. この利用許諾は、あなたがこの利用許諾の条項に違反すると自動的に終了する。しかし、本作品、その二次的著作物又は編集著作物等をあなたからこの利用許諾に基づき受領した第三者に対しては、その受領者がこの利用許諾を遵守している限り、この利用許諾は終了しない。第1条、第2条、第4条から第9条は、この利用許諾が終了してもなお有効に存続する。
|
||||
b. 上記aに定める場合を除き、この利用許諾に基づくライセンスは、本作品に含まれる著作権法上の権利が存続するかぎり継続する。
|
||||
c. 許諾者は、上記aおよびbに関わらず、いつでも、本作品をこの利用許諾に基づいて頒布することを将来に向かって中止することができる。ただし、許諾者がこの利用許諾に基づく頒布を将来に向かって中止した場合でも、この利用許諾に基づいてすでに本作品を受領した利用者に対しては、この利用許諾に基づいて過去及び将来に与えられるいかなるライセンスも終了することはない。また、上記によって終了しない限り、この利用許諾は、全面的に有効なものとして継続する。
|
||||
|
||||
第8条 その他
|
||||
|
||||
a. この利用許諾のいずれかの規定が、適用法の下で無効及び/又は執行不能の場合であっても、この利用許諾の他の条項の有効性及び執行可能性には影響しない。
|
||||
b. この利用許諾の条項の全部又は一部の放棄又はその違反に関する承諾は、これが書面にされ、当該放棄又は承諾に責任を負う当事者による署名又は記名押印がなされない限り、行うことができない。
|
||||
c. この利用許諾は、当事者が本作品に関して行った最終かつ唯一の合意の内容である。この利用許諾は、許諾者とあなたとの相互の書面による合意なく修正されない。
|
||||
d. この利用許諾は日本語により提供される。この利用許諾の英語その他の言語への翻訳は参照のためのものに過ぎず、この利用許諾の日本語版と翻訳との間に何らかの齟齬がある場合には日本語版が優先する。
|
||||
|
||||
第9条 準拠法
|
||||
|
||||
この利用許諾は、日本法に基づき解釈される。
|
||||
|
||||
本作品がクリエイティブ・コモンズ・ライセンスに基づき利用許諾されたことを公衆に示すという限定された目的の場合を除き、許諾者も被許諾者もクリエイティブ・コモンズの事前の書面による同意なしに「クリエイティブ・コモンズ」の商標若しくは関連商標又はクリエイティブ・コモンズのロゴを使用しないものとします。使用が許可された場合はクリエイティブ・コモンズおよびクリエイティブ・コモンズ・ジャパンのウェブサイト上に公表される、又はその他随時要求に従い利用可能となる、クリエイティブ・コモンズの当該時点における商標使用指針を遵守するものとします。クリエイティブ・コモンズは https://creativecommons.org/から、クリエイティブ・コモンズ・ジャパンはhttp://www.creativecommons.jp/から連絡することができます。
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<style>
|
||||
html,body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
background-color: #000;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var json = {
|
||||
command: "MnemonicMode",
|
||||
url: "http://127.0.0.1:9314/api/login/loginByMnemonic"
|
||||
};
|
||||
</script>
|
||||
<body>
|
||||
<button style="display: none;" onclick="osnsdk.run(JSON.stringify(json))">跳转</button>
|
||||
</body>
|
||||
<script>
|
||||
try{
|
||||
osnsdk.run(JSON.stringify(json));
|
||||
}catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
window.onload = function (){
|
||||
try{
|
||||
osnsdk.run(JSON.stringify(json));
|
||||
}catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
<sourceRoots>
|
||||
<root url="file://$MODULE_DIR$/src/main/java" />
|
||||
<root url="file://$MODULE_DIR$/src/main/resources" />
|
||||
</sourceRoots>
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.29" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.27" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.27" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.27" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-devtools:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.activation:jakarta.activation-api:1.2.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.5.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.43.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.43.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.43.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.43.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.43.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.43.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: ospn-old:ospn-old:1.7" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.29" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.xiaoymin:swagger-bootstrap-ui:1.9.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.70" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.69" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,316 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`\\unset -f command; \\command -v java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@@ -0,0 +1,188 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
||||
Binary file not shown.
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.1.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.test</groupId>
|
||||
<artifactId>usersvc</artifactId>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
<name>usersvc</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ospn-old</groupId>
|
||||
<artifactId>ospn-old</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.70</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.69</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
<!--多环境参数配置-->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<profilesActive>dev</profilesActive>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<properties>
|
||||
<profilesActive>test</profilesActive>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<profilesActive>prod</profilesActive>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mhhy;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.mhhy.mapper")
|
||||
public class MhhyFramworkApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MhhyFramworkApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mhhy;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Lazy(false)
|
||||
public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
|
||||
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
|
||||
/**
|
||||
* 取得存储在静态变量中的ApplicationContext.
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
return (T) applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> requiredType) {
|
||||
return applicationContext.getBean(requiredType);
|
||||
}
|
||||
|
||||
public static <T> T getBean(String name, Class<T> clazz) {
|
||||
return getApplicationContext().getBean(name, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除SpringContextHolder中的ApplicationContext为Null.
|
||||
*/
|
||||
public static void clearHolder() {
|
||||
applicationContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现ApplicationContextAware接口, 注入Context到静态变量中.
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext appContext) {
|
||||
applicationContext = appContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现DisposableBean接口, 在Context关闭时清理静态变量.
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
SpringContextHolder.clearHolder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mhhy.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 用于标记接口登录、参数解密,标记的非加密接口必须登录
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Login {
|
||||
|
||||
//该接口是否加密
|
||||
boolean encrypted() default false;
|
||||
|
||||
//AES解密密钥,在encrypted为true时有效,若不指定,则从当前token中获取
|
||||
String key() default "";
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mhhy.common;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BasePageReq {
|
||||
|
||||
//最后一条数据的id
|
||||
//private int lastId;
|
||||
|
||||
//分页页码,从1开始
|
||||
@ApiModelProperty(value = "分页页码,从1开始")
|
||||
private int page = 1;
|
||||
|
||||
//分页大小,默认10
|
||||
@ApiModelProperty(value = "分页大小,默认10")
|
||||
private int size = 10;
|
||||
|
||||
//获取page对象,用于mybatis-plus
|
||||
public IPage<?> getIPage() {
|
||||
return new Page<>(page, size).setSearchCount(false);
|
||||
}
|
||||
|
||||
//获取offset,用于手动处理sql
|
||||
public int getOffset() {
|
||||
return page > 1 ? page * size - size : 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.mhhy.common;
|
||||
|
||||
import com.mhhy.util.Aes128Util;
|
||||
import com.mhhy.util.PasswordUtil;
|
||||
import com.mhhy.util.RedisUtil;
|
||||
import com.mhhy.util.RequestUtil;
|
||||
import com.ospn.common.OsnUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import static com.mhhy.service.impl.LoginServiceImpl.conversationFlag;
|
||||
|
||||
@Data
|
||||
//@Builder
|
||||
public class BaseResult<T> {
|
||||
|
||||
private int code = 200;
|
||||
|
||||
private String msg = "Success";
|
||||
|
||||
private long timeMillis = System.currentTimeMillis();
|
||||
|
||||
private Object data;
|
||||
|
||||
public BaseResult() {
|
||||
}
|
||||
|
||||
public BaseResult(Object data) {
|
||||
int mainUserId = RequestUtil.getMainUserId();
|
||||
String conversationId = RedisUtil.get(conversationFlag + mainUserId);
|
||||
byte[] sha256Str = PasswordUtil.getSHA256Str(conversationId);
|
||||
data = Aes128Util.AESEncode(data.toString(), sha256Str);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public BaseResult(String data, String key) {
|
||||
//byte[] sha256Str = PasswordUtil.decodeBase64(key);
|
||||
System.out.println("[BaseResult success] key:" + key);
|
||||
this.data = OsnUtils.aesEncrypt(data, key);
|
||||
//this.data = Aes128Util.AESEncode(data.toString(), sha256Str);
|
||||
}
|
||||
|
||||
public BaseResult(Object data, String key, int type) {
|
||||
if (type == 1){
|
||||
byte[] sha256Str = PasswordUtil.getSHA256Str(key);
|
||||
this.data = Aes128Util.AESEncode(data.toString(), sha256Str);
|
||||
} else if (type == 0) {
|
||||
byte[] sha256Str = PasswordUtil.decodeBase64(key);
|
||||
this.data = Aes128Util.AESEncode(data.toString(), sha256Str);
|
||||
}
|
||||
}
|
||||
|
||||
public BaseResult(int code, Object data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BaseResult(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static BaseResult<?> success(String msg) {
|
||||
return new BaseResult<>(200, msg);
|
||||
}
|
||||
|
||||
public static BaseResult<?> success(int code, Object msg) {
|
||||
return new BaseResult<>(200, msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static BaseResult<?> success() {
|
||||
return new BaseResult<>(200, "success");
|
||||
}
|
||||
|
||||
|
||||
public static BaseResult<?> err(String msg) {
|
||||
return new BaseResult<>(500, msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mhhy.config.jwt;
|
||||
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@Configuration
|
||||
public class JwtConfig {
|
||||
|
||||
public static final String JWT_SECRET = "mhhy2022";
|
||||
|
||||
@Bean
|
||||
public Algorithm algorithm() throws UnsupportedEncodingException {
|
||||
return Algorithm.HMAC256(JWT_SECRET);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mhhy.config.redis;
|
||||
|
||||
import com.mhhy.util.Md5Util;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class CacheKeyGenerator implements KeyGenerator {
|
||||
|
||||
@Override
|
||||
public Object generate(Object target, Method method, Object... params) {
|
||||
String className = target.getClass().getName();
|
||||
String methodName = method.getName();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
//builder.append(className).append("&");
|
||||
//builder.append(methodName).append("&");
|
||||
if (params.length > 0) {
|
||||
int i = 0;
|
||||
while (i < params.length) {
|
||||
builder.append(params[i++].toString()).append("&");
|
||||
}
|
||||
}
|
||||
return className + ":" + methodName + ":" + Md5Util.md5(builder.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mhhy.config.redis;
|
||||
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class OdcCacheManager extends RedisCacheManager {
|
||||
|
||||
private static final String SEPARATOR = "#";
|
||||
|
||||
public OdcCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration config) {
|
||||
super(cacheWriter, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RedisCache createRedisCache(String name, RedisCacheConfiguration cacheConfig) {
|
||||
String[] values = name.split(SEPARATOR);
|
||||
if (values.length > 1) {
|
||||
long second = Long.parseLong(values[1]);
|
||||
cacheConfig = cacheConfig.entryTtl(Duration.ofSeconds(second));
|
||||
}
|
||||
return super.createRedisCache(name, cacheConfig);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mhhy.config.redis;
|
||||
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
//默认过期时间,1 min
|
||||
private final static int EXPIRATION_SECOND = 20;
|
||||
|
||||
public final static String KEY_GENERATOR_NAME = "odcKeyGenerator";
|
||||
|
||||
public final static String CACHE_KEY = "vexCache";
|
||||
|
||||
@Bean
|
||||
public RedisCacheManager redisCacheManager(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisSerializationContext.SerializationPair<Object> valuePair =
|
||||
RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
|
||||
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory);
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
|
||||
.entryTtl(Duration.ofSeconds(EXPIRATION_SECOND))
|
||||
.serializeValuesWith(valuePair)
|
||||
.disableCachingNullValues();
|
||||
return new OdcCacheManager(redisCacheWriter, config);
|
||||
}
|
||||
|
||||
@Bean(value = KEY_GENERATOR_NAME)
|
||||
public KeyGenerator keyGenerator() {
|
||||
return new CacheKeyGenerator();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mhhy.config.redis;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
|
||||
@Configuration
|
||||
public class RedisListenerConfig {
|
||||
@Bean
|
||||
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mhhy.config.web;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@Configuration
|
||||
public class LocaleConfig {
|
||||
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
|
||||
localeResolver.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
|
||||
return localeResolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageSource messageSource() {
|
||||
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
messageSource.setBasename("classpath:/i18n/messages");
|
||||
messageSource.setDefaultEncoding("UTF-8");
|
||||
messageSource.setCacheSeconds(60);
|
||||
return messageSource;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mhhy.config.web;
|
||||
|
||||
import com.mhhy.common.BaseResult;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
//@Configuration
|
||||
//@RestControllerAdvice
|
||||
public class OdcResponseBodyAdvice implements ResponseBodyAdvice {
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Class aClass) {
|
||||
Method method = methodParameter.getMethod();
|
||||
return method != null
|
||||
&& !method.getDeclaringClass().getPackage().getName().startsWith("springfox");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object body, MethodParameter methodParameter, MediaType mediaType, Class aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
|
||||
if (body instanceof BaseResult) {
|
||||
return body;
|
||||
}
|
||||
return new BaseResult<>(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mhhy.config.web;
|
||||
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
|
||||
MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
|
||||
jacksonConverter.setSupportedMediaTypes(
|
||||
Arrays.asList(
|
||||
MediaType.APPLICATION_JSON,
|
||||
MediaType.TEXT_HTML
|
||||
));
|
||||
|
||||
RestTemplate restTemplate = restTemplateBuilder.build();
|
||||
restTemplate.getMessageConverters().add(jacksonConverter);
|
||||
return restTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mhhy.config.web;
|
||||
|
||||
|
||||
|
||||
import com.mhhy.interceptor.AuthInterceptor;
|
||||
import com.mhhy.resolver.DecodeArgumentResolver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig extends WebMvcConfigurationSupport {
|
||||
|
||||
@Autowired
|
||||
private AuthInterceptor authInterceptor;
|
||||
|
||||
@Autowired
|
||||
private DecodeArgumentResolver decodeArgumentResolver;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authInterceptor).addPathPatterns("/api/**");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HttpMessageConverters httpMessageConverters() {
|
||||
return new HttpMessageConverters(
|
||||
Arrays.asList(
|
||||
new StringHttpMessageConverter(Charset.forName("UTF-8")),
|
||||
//new FastJsonHttpMessageConverter(),
|
||||
new MappingJackson2HttpMessageConverter())
|
||||
);
|
||||
}
|
||||
|
||||
// //不可用
|
||||
// @Bean
|
||||
// public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
|
||||
// return m -> {
|
||||
// m.serializerByType(BaseEnum.class, BaseEnumSerializer.getInstance());
|
||||
// m.serializerByType(BigDecimal.class, CoinNumSerializer.getInstance());
|
||||
// };
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(decodeArgumentResolver);
|
||||
}
|
||||
|
||||
//@Override
|
||||
//protected void addFormatters(FormatterRegistry registry) {
|
||||
// //super.addFormatters(registry);
|
||||
// registry.addConverterFactory(new EnumTypeConverterFactory());
|
||||
//}
|
||||
|
||||
@Override
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/static/**")
|
||||
.addResourceLocations("classpath:/static/");
|
||||
registry.addResourceHandler("doc.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
super.addResourceHandlers(registry);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.enums.UserStateEnum;
|
||||
import com.mhhy.enums.UserTypeEnum;
|
||||
import com.mhhy.model.entity.AdminEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.model.req.*;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
import com.mhhy.model.struct.LoginResult;
|
||||
import com.mhhy.service.*;
|
||||
import com.mhhy.util.RandomUtil;
|
||||
import com.mhhy.util.RedisUtil;
|
||||
import com.mhhy.util.RequestUtil;
|
||||
import com.mhhy.util.token.JwtUtil;
|
||||
import com.ospn.command.CmdReDappLogin;
|
||||
import com.ospn.data.DappData;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/admin")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class AdminController {
|
||||
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
AdminService adminService;
|
||||
|
||||
@Autowired
|
||||
LoginService loginService;
|
||||
|
||||
@Autowired
|
||||
LtpServer ltpServer;
|
||||
|
||||
|
||||
@PostMapping("/register")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "注册", response = RegisterReq.class)
|
||||
public BaseResult register(@RequestBody RegisterReq req) {
|
||||
|
||||
|
||||
String username = req.getUsername();
|
||||
String password = req.getPassword();
|
||||
int level = req.getLevel();
|
||||
|
||||
UserEntity userEntity = userService.findAdmin(username);
|
||||
|
||||
if (userEntity != null) {
|
||||
return BaseResult.err("user existed.");
|
||||
}
|
||||
|
||||
userEntity = new UserEntity();
|
||||
userEntity.setState(level);
|
||||
userEntity.setUsername(username);
|
||||
userEntity.setPassword(password);
|
||||
|
||||
// 存入db
|
||||
boolean result = false;
|
||||
|
||||
/*if (level == 1) {
|
||||
result = adminService.createAdmin(username, password);
|
||||
} else if (level == 2) {
|
||||
result = adminService.createCustomer(username, password);
|
||||
}*/
|
||||
result = userService.save(userEntity);
|
||||
|
||||
if (result) {
|
||||
return BaseResult.success(200, "success.");
|
||||
} else {
|
||||
return BaseResult.err("register error.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/login")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult login(@RequestBody LoginReq req) {
|
||||
|
||||
//RequestUtil.getMainUser();
|
||||
|
||||
String username = req.getUsername();
|
||||
|
||||
UserEntity userEntity = userService.getOne(
|
||||
new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getUsername, username));
|
||||
if (userEntity == null) {
|
||||
return BaseResult.err("no user");
|
||||
}
|
||||
|
||||
if (!userEntity.getPassword().equalsIgnoreCase(req.getPassword())) {
|
||||
return BaseResult.err("password error.");
|
||||
}
|
||||
|
||||
//LoginResult result = new LoginResult(userEntity, loginService.getConfig(), ltpServer.getAppId());
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("level", userEntity.getState());
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/modifyAdminPwd")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "modify admin password", response = RegisterReq.class)
|
||||
public BaseResult modifyAdminPwd(@RequestBody RegisterReq req) {
|
||||
|
||||
String username = req.getUsername();
|
||||
String password = req.getPassword();
|
||||
|
||||
UserEntity adminEntity = userService.findAdmin(username);
|
||||
if (adminEntity == null) {
|
||||
return BaseResult.err("user not exist.");
|
||||
}
|
||||
adminEntity.setPassword(password);
|
||||
|
||||
if (!userService.updateById(adminEntity)) {
|
||||
return BaseResult.err("update password failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "success.");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/listAdmin")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult listAdmin(@RequestBody FindUserReq req) {
|
||||
|
||||
int page = req.getPage();
|
||||
int limit = req.getLimit();
|
||||
|
||||
|
||||
List<UserEntity> list = userService.listAdmin(page, limit);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("list", list);
|
||||
|
||||
int count = userService.count(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getState, 2));
|
||||
result.put("count", count);
|
||||
/*int fixPage = 0;
|
||||
if (count%limit > 0) {
|
||||
fixPage ++;
|
||||
}
|
||||
result.put("page", count/limit + fixPage);*/
|
||||
result.put("page", page);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/listUser")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult listUser(@RequestBody FindUserReq req) {
|
||||
|
||||
int page = req.getPage();
|
||||
int limit = req.getLimit();
|
||||
String project = req.getProject();
|
||||
|
||||
List<UserEntity> list = userService.listUser(page, limit, project);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("list", list);
|
||||
|
||||
int count = userService.count(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getProject, project));
|
||||
result.put("count", count);
|
||||
/*int fixPage = 0;
|
||||
if (count%limit > 0) {
|
||||
fixPage ++;
|
||||
}
|
||||
result.put("page", count/limit + fixPage);*/
|
||||
result.put("page", page);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
@PostMapping("/disableUser")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult disableUser(@RequestBody FindUserReq req) {
|
||||
|
||||
String username = req.getOsnId();
|
||||
|
||||
if (loginService.disableOrEnableUser(username, false)) {
|
||||
UserEntity userEntity = userService.getUser(username);
|
||||
if (userEntity != null) {
|
||||
userEntity.setState(0);
|
||||
userService.updateById(userEntity);
|
||||
}
|
||||
return BaseResult.success(200, "success.");
|
||||
}
|
||||
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
@PostMapping("/enableUser")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult enableUser(@RequestBody FindUserReq req) {
|
||||
|
||||
String username = req.getOsnId();
|
||||
|
||||
if (loginService.disableOrEnableUser(username, true)) {
|
||||
UserEntity userEntity = userService.getUser(username);
|
||||
if (userEntity != null) {
|
||||
userEntity.setState(1);
|
||||
userService.updateById(userEntity);
|
||||
}
|
||||
return BaseResult.success(200, "success.");
|
||||
}
|
||||
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult query(@RequestBody FindUserReq req) {
|
||||
|
||||
String username = req.getOsnId();
|
||||
JSONObject result = new JSONObject();
|
||||
UserEntity userEntity = userService.getUser(username);
|
||||
if (userEntity != null) {
|
||||
List<UserEntity> list = new ArrayList<>();
|
||||
list.add(userEntity);
|
||||
|
||||
result.put("list", list);
|
||||
result.put("count", 1);
|
||||
result.put("page", 1);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/genDappInfo")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult genDappInfo(@RequestBody ReqBase req) {
|
||||
|
||||
|
||||
DappData dappData = new DappData();
|
||||
dappData.url = req.getUrl();
|
||||
dappData.name = ltpServer.ltpData.dappInfo.name;
|
||||
dappData.portrait = ltpServer.ltpData.dappInfo.portrait;
|
||||
dappData.theme = ltpServer.ltpData.dappInfo.theme;
|
||||
dappData.osnID = ltpServer.ltpData.apps.osnID;
|
||||
|
||||
JSONObject result = dappData.toClientJsonNoParam(ltpServer.ltpData.apps.osnKey);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/flushUser")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult flushUser(@RequestBody FindUserReq req) {
|
||||
|
||||
String osnId = req.getOsnId();
|
||||
if (osnId == null) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
ltpServer.getUserInfo(osnId);
|
||||
|
||||
return BaseResult.success();
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/flushGroup")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult flushGroup(@RequestBody FindUserReq req) {
|
||||
|
||||
String osnId = req.getOsnId();
|
||||
if (osnId == null) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
ltpServer.getGroupInfo(osnId);
|
||||
|
||||
return BaseResult.success();
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/delete-user")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "代理商删除", response = LoginResp.class)
|
||||
public BaseResult deleteUser(@RequestBody UserEntity user) {
|
||||
UserEntity userEntity = userService.getOne(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getUsername, user.getUsername()));
|
||||
if (userEntity != null) {
|
||||
if (!userService.removeById(userEntity.getId())) {
|
||||
return BaseResult.err("delete failed.");
|
||||
}
|
||||
}
|
||||
return BaseResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.AppVersionEntity;
|
||||
import com.mhhy.model.req.FindAppVersionReq;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
import com.mhhy.service.AppVersionEntityService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/im")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class AppVersionEntityController {
|
||||
|
||||
AppVersionEntityService appVersionEntityService;
|
||||
|
||||
@PostMapping("/list")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "版本信息分页查询", response = LoginResp.class)
|
||||
public BaseResult list(@RequestBody FindAppVersionReq req) {
|
||||
|
||||
int page = req.getPage();
|
||||
int limit = req.getLimit();
|
||||
|
||||
|
||||
List<AppVersionEntity> list = appVersionEntityService.listAppVersion(page, limit);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("list", list);
|
||||
|
||||
int count = appVersionEntityService.count();
|
||||
result.put("count", count);
|
||||
result.put("page", page);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
@PostMapping("/list-version")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "版本信息条件分页查询", response = LoginResp.class)
|
||||
public BaseResult listVersion(@RequestBody FindAppVersionReq req) {
|
||||
|
||||
int page = req.getPage();
|
||||
int limit = req.getLimit();
|
||||
|
||||
|
||||
List<AppVersionEntity> list = appVersionEntityService.listAppVersionUser(page, limit, req.getUser());
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("list", list);
|
||||
|
||||
int count = appVersionEntityService.count();
|
||||
result.put("count", count);
|
||||
result.put("page", page);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/all")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "查询全部版本信息", response = LoginResp.class)
|
||||
public BaseResult allVersion() {
|
||||
|
||||
List<AppVersionEntity> list = appVersionEntityService.listAppVersionAll();
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("data", list);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
@PostMapping("/get-app-version")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "查询user版本信息", response = LoginResp.class)
|
||||
public BaseResult getVersionUser() {
|
||||
|
||||
AppVersionEntity list = appVersionEntityService.getUser();
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("data", list);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/delete")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "删除user版本信息", response = LoginResp.class)
|
||||
public BaseResult delete(@RequestBody FindAppVersionReq req) {
|
||||
|
||||
AppVersionEntity appVersionEntity = appVersionEntityService.getById(req.getId());
|
||||
appVersionEntity.setIsShow(1);
|
||||
appVersionEntityService.save(appVersionEntity);
|
||||
return BaseResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/update")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "更新user版本信息", response = LoginResp.class)
|
||||
public BaseResult update(@RequestBody AppVersionEntity req) {
|
||||
|
||||
AppVersionEntity appVersionEntity = appVersionEntityService.getById(req.getId());
|
||||
appVersionEntity.setIsShow(1);
|
||||
req.setUpdateTime(new Date());
|
||||
appVersionEntityService.save(appVersionEntity);
|
||||
return BaseResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/add")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "新增user版本信息", response = LoginResp.class)
|
||||
public BaseResult add(@RequestBody AppVersionEntity req) {
|
||||
|
||||
req.setCreateTime(new Date());
|
||||
req.setUpdateTime(new Date());
|
||||
req.setState(2);
|
||||
req.setIsShow(0);
|
||||
if (!appVersionEntityService.save(req)){
|
||||
return BaseResult.err("add failed.");
|
||||
}
|
||||
return BaseResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.model.req.CustomerReq;
|
||||
import com.mhhy.model.req.LoginReq;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
import com.mhhy.service.CustomerService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/customer")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class CustomerController {
|
||||
|
||||
@Autowired
|
||||
CustomerService customerService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "add", response = LoginResp.class)
|
||||
public BaseResult add(@RequestBody CustomerReq req) {
|
||||
|
||||
if (!customerService.addObj(req.getName(), req.getPortrait(), req.getOsnId(), req.getProject()) ) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "success.");
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "list", response = LoginResp.class)
|
||||
public BaseResult list(@RequestBody CustomerReq req) {
|
||||
|
||||
List list = customerService.listByProject(req.getProject());
|
||||
|
||||
return BaseResult.success(200, list);
|
||||
}
|
||||
|
||||
@PostMapping("/del")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "del", response = LoginResp.class)
|
||||
public BaseResult del(@RequestBody CustomerReq req) {
|
||||
|
||||
if (!customerService.deleteObj(req.getOsnId(), req.getProject())){
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "login success.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.req.CustomerReq;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
import com.mhhy.service.GroupService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/group")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class GroupController {
|
||||
|
||||
@Autowired
|
||||
GroupService groupService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "add", response = LoginResp.class)
|
||||
public BaseResult add(@RequestBody CustomerReq req) {
|
||||
|
||||
if (!groupService.addObj(req.getName(), req.getPortrait(), req.getOsnId(), req.getProject()) ) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "success.");
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "list", response = LoginResp.class)
|
||||
public BaseResult list(@RequestBody CustomerReq req) {
|
||||
|
||||
List list = groupService.listByProject(req.getProject());
|
||||
|
||||
return BaseResult.success(200, list);
|
||||
}
|
||||
|
||||
@PostMapping("/del")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "del", response = LoginResp.class)
|
||||
public BaseResult del(@RequestBody CustomerReq req) {
|
||||
|
||||
if (!groupService.deleteObj(req.getOsnId(), req.getProject())){
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "login success.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/im")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class ImController {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.enums.UserStateEnum;
|
||||
import com.mhhy.enums.UserTypeEnum;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.model.req.DappRequest;
|
||||
import com.mhhy.model.req.LoginReq;
|
||||
import com.mhhy.model.req.RegisterReq;
|
||||
import com.mhhy.model.req.UpdatePasswdReq;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
import com.mhhy.model.struct.LoginResult;
|
||||
import com.mhhy.service.LoginService;
|
||||
import com.mhhy.service.LtpServer;
|
||||
import com.mhhy.service.ProjectConfigService;
|
||||
import com.mhhy.service.UserService;
|
||||
import com.mhhy.util.RandomUtil;
|
||||
import com.mhhy.util.RedisUtil;
|
||||
import com.mhhy.util.token.JwtUtil;
|
||||
import com.ospn.command.CmdReDappLogin;
|
||||
import com.ospn.common.ECUtils;
|
||||
import com.ospn.data.DappData;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("api/login")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
LoginService loginService;
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
ProjectConfigService configService;
|
||||
|
||||
|
||||
@Autowired
|
||||
LtpServer ltpServer;
|
||||
|
||||
|
||||
|
||||
@PostMapping("/login")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult login(@RequestBody LoginReq req){
|
||||
return loginService.login(req);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation("dapp login")
|
||||
@CrossOrigin(origins = "*")
|
||||
@PostMapping("/dappLogin")
|
||||
public JSONObject dappLogin(@RequestBody DappRequest cmd) {
|
||||
//log.info("传递的参数是:{}", cmd);
|
||||
|
||||
JSONObject ret = null;
|
||||
if (cmd.command.equalsIgnoreCase("GetServerInfo")) {
|
||||
|
||||
// key: dapp_session_user
|
||||
String session = RedisUtil.get("dapp_session_" + cmd.user);
|
||||
|
||||
if (session != null) {
|
||||
// 返回数据
|
||||
ret = ltpServer.ltpData.getServerInfo(cmd.getCmdGetServerInfo(session));
|
||||
} else {
|
||||
ret = ltpServer.ltpData.getServerInfo(cmd.getCmdGetServerInfo());
|
||||
session = ret.getString("session");
|
||||
RedisUtil.setEx("dapp_session_" + cmd.user, session, 60);
|
||||
}
|
||||
|
||||
} else if (cmd.command.equalsIgnoreCase("Login")) {
|
||||
|
||||
CmdReDappLogin cmdRe = null;
|
||||
try {
|
||||
|
||||
UserEntity userEntity = userService.getOne(
|
||||
new QueryWrapper<UserEntity>()
|
||||
.eq("im_id", cmd.user)
|
||||
);
|
||||
if (userEntity != null){
|
||||
cmdRe.setError("1007:no user");
|
||||
return cmdRe.toJson();
|
||||
}
|
||||
|
||||
String session = RedisUtil.get("dapp_session_" + cmd.user);
|
||||
if (session == null) {
|
||||
// 没有session,返回错误信息
|
||||
cmdRe = new CmdReDappLogin();
|
||||
cmdRe.setError("1001:need session");
|
||||
return cmdRe.toJson();
|
||||
}
|
||||
|
||||
|
||||
cmdRe = ltpServer.ltpData.login(cmd.getCmdDappLogin(session));
|
||||
|
||||
if (cmdRe.errCode.equalsIgnoreCase("0:success")) {
|
||||
|
||||
// 增加sessionKey
|
||||
// 生成jwtToken
|
||||
|
||||
|
||||
String randomToInviteCode = RandomUtil.getRandomToInviteCode(16);
|
||||
String token = JwtUtil.createJwtToken(userEntity.getId(), 315360000L);
|
||||
//把之前的token移除
|
||||
JwtUtil.removeTokenByUserId(userEntity.getId());
|
||||
//把token存入redis
|
||||
JwtUtil.putTokenToRedis(userEntity.getId(), token);
|
||||
JSONObject tokenJson = new JSONObject();
|
||||
// TODO 生成通讯密钥拼接在token后面用中竖线隔开,小程序端需要用中划线分割出token
|
||||
tokenJson.put("token", token);
|
||||
tokenJson.put("communicationKey", randomToInviteCode);
|
||||
// log.info("-------token-------" + tokenJson.get("token"));
|
||||
//将通讯密钥存入redis
|
||||
RedisUtil.set("Communicationkey:"+cmd.user, randomToInviteCode);
|
||||
|
||||
cmdRe.addSessionKey(cmd.user, tokenJson.toString().getBytes());
|
||||
|
||||
return cmdRe.toJson();
|
||||
|
||||
} else {
|
||||
ret = cmdRe.toJson();
|
||||
}
|
||||
|
||||
|
||||
return cmdRe.toJson();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
cmdRe.setError("1006:exception");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/register2")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "注册", response = LoginResp.class)
|
||||
public BaseResult register2(@RequestBody RegisterReq req){
|
||||
|
||||
String key = req.getKey();
|
||||
if (!loginService.getRegisterKey().equals(key)) {
|
||||
return BaseResult.err("register key error.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
String username = req.getAccount();
|
||||
String password = req.getPassword();
|
||||
|
||||
String osnId1 = userService.findUser(username);
|
||||
|
||||
if (osnId1 != null) {
|
||||
return BaseResult.err("user existed.");
|
||||
}
|
||||
|
||||
String[] keyPair =loginService.createAccount();
|
||||
String privateKey = "VER2-" + keyPair[1] + "-" + keyPair[2];
|
||||
|
||||
// 存入db
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setUsername(username);
|
||||
userEntity.setPassword(password);
|
||||
userEntity.setType(UserTypeEnum.NORMAL.getCode());
|
||||
userEntity.setState(UserStateEnum.NORMAL.getCode());
|
||||
userEntity.setCreateTime(new Date());
|
||||
userEntity.setImNode(loginService.getHostIp());
|
||||
userEntity.setImId(keyPair[0]);
|
||||
userEntity.setImUsername(keyPair[0]);
|
||||
userEntity.setImPwd(privateKey);
|
||||
userEntity.setProject(req.getProject());
|
||||
try {
|
||||
userService.save(userEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return BaseResult.err("exception.");
|
||||
}
|
||||
|
||||
// 返回成功
|
||||
return BaseResult.success(200,"success.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/getChallenge")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "获取登录的随机数", response = LoginResp.class)
|
||||
public BaseResult getChallenge(@RequestBody RegisterReq req){
|
||||
return loginService.getChallenge(req.getUsername());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private JSONObject createAccount() {
|
||||
|
||||
try {
|
||||
String username = UUID.randomUUID().toString().replace("-", "").substring(2, 22);
|
||||
String password = UUID.randomUUID().toString().replace("-", "").substring(2, 22);
|
||||
|
||||
RegisterReq req1 = new RegisterReq();
|
||||
req1.setUsername(username);
|
||||
req1.setPassword(password);
|
||||
|
||||
JSONObject result = loginService.register3(req1);
|
||||
if (result != null) {
|
||||
result.put("username", username);
|
||||
result.put("password", password);
|
||||
return result;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/login3")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult loginByMnemonic(@RequestBody LoginReq req){
|
||||
|
||||
try {
|
||||
System.out.print("[loginByMnemonic] login begin.\n");
|
||||
System.out.print("[loginByMnemonic] req : " + req);
|
||||
|
||||
String project = req.getInvite();
|
||||
if (project == null) {
|
||||
return BaseResult.err("no project");
|
||||
}
|
||||
JSONObject config = configService.getConfig(project);
|
||||
if (config == null) {
|
||||
return BaseResult.err("no config");
|
||||
}
|
||||
|
||||
String user = req.getUser();
|
||||
|
||||
// 从user 表中查找
|
||||
UserEntity userEntity = userService.getUser(user);
|
||||
if (userEntity == null) {
|
||||
// 进入注册环节
|
||||
userEntity = loginService.register6(user, null, project);
|
||||
}
|
||||
|
||||
if (userEntity == null) {
|
||||
System.out.print("[loginByMnemonic] login failed.");
|
||||
return BaseResult.err("create user failed.");
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
//result.put("osn_node", config.getString("HOST_IP"));
|
||||
|
||||
String token = JwtUtil.createJwtToken(userEntity.getId(), 315360000L);
|
||||
//把之前的token移除
|
||||
JwtUtil.removeTokenByUserId(userEntity.getId());
|
||||
//把token存入redis
|
||||
JwtUtil.putTokenToRedis(userEntity.getId(), token);
|
||||
|
||||
result.put("token", token);
|
||||
result.put("language", "en");
|
||||
// 新增修复
|
||||
config = configService.getConfig(userEntity.getProject());
|
||||
result.put("json", config);
|
||||
result.put("osn_node", userEntity.getImNode());
|
||||
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return BaseResult.err("Exception.");
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/loginByMnemonic2")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult loginByMnemonic2(@RequestBody LoginReq req){
|
||||
|
||||
System.out.print("[loginByMnemonic2] login begin.");
|
||||
|
||||
JSONObject config = loginService.getConfig();
|
||||
if (config == null) {
|
||||
return BaseResult.err("no config");
|
||||
}
|
||||
|
||||
String user = req.getUser();
|
||||
|
||||
// 从user 表中查找
|
||||
UserEntity userEntity = userService.getUser(user);
|
||||
if (userEntity == null) {
|
||||
// 进入注册环节
|
||||
userEntity = loginService.register6(user, null, null);
|
||||
}
|
||||
|
||||
if (userEntity == null) {
|
||||
System.out.print("[loginByMnemonic] login failed.");
|
||||
return BaseResult.err("");
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("osn_node", config.getString("HOST_IP"));
|
||||
|
||||
String token = JwtUtil.createJwtToken(userEntity.getId(), 315360000L);
|
||||
//把之前的token移除
|
||||
JwtUtil.removeTokenByUserId(userEntity.getId());
|
||||
//把token存入redis
|
||||
JwtUtil.putTokenToRedis(userEntity.getId(), token);
|
||||
|
||||
result.put("token", token);
|
||||
result.put("language", "en");
|
||||
result.put("json", config);
|
||||
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
@PostMapping("/login2")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult login2(@RequestBody LoginReq req){
|
||||
|
||||
String username = req.getAccount();
|
||||
|
||||
UserEntity userEntity = userService.getOne(
|
||||
new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getUsername, username));
|
||||
if (userEntity == null) {
|
||||
return BaseResult.err("no user");
|
||||
}
|
||||
|
||||
if (!userEntity.getPassword().equalsIgnoreCase(req.getPassword())) {
|
||||
return BaseResult.err("password error.");
|
||||
}
|
||||
|
||||
LoginResult result = new LoginResult(userEntity, loginService.getConfig(), ltpServer.getAppId());
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/generateDappInfo")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public JSONObject generateDappInfo(@RequestBody LoginReq req){
|
||||
|
||||
String url = req.getUrl();
|
||||
return generateDappInfo(url, null, null);
|
||||
}
|
||||
|
||||
private JSONObject generateDappInfo(String url, String name, String portrait) {
|
||||
|
||||
try {
|
||||
String[] keyPair = ECUtils.createOsnID("service");
|
||||
|
||||
DappData dappData = new DappData();
|
||||
dappData.url = url;
|
||||
dappData.osnID = keyPair[0];
|
||||
dappData.name = name;
|
||||
dappData.portrait = portrait;
|
||||
|
||||
return dappData.toClientJsonNoParam(keyPair[1]);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/createConfigInfo")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "登录", response = LoginResp.class)
|
||||
public BaseResult createConfigInfo(@RequestBody LoginReq req){
|
||||
|
||||
String url = req.getUrl();
|
||||
String project = req.getProject();
|
||||
|
||||
/**
|
||||
* config 格式
|
||||
* json
|
||||
* HOST_IP: 8.219.11.57
|
||||
* ENDPOINT: https://oss-ap-southeast-1.aliyuncs.com
|
||||
* AccessKeyId: LTAI5tE1VjrLkUhQisYmYJEc
|
||||
* AccessKeySecret: FxAfo6vhJCcyQ4RHKz9hGG97RVL9Ta
|
||||
* BUCKETNAME: imx1-default
|
||||
* UserPortraitDirectory: portrait/
|
||||
* GroupPortraitDirectory: portrait/
|
||||
* TempDirectory: temp/
|
||||
* WEBRTCBASE: webrtc://103.163.46.118:1985/live/android/
|
||||
* WEBRTCHOST: http://103.163.46.118:1985
|
||||
* */
|
||||
|
||||
try {
|
||||
JSONObject config = loginService.getConfig();
|
||||
|
||||
JSONObject mainDapp = generateDappInfo(url, null, null);
|
||||
String base64Str = Base64.getEncoder().encodeToString(mainDapp.toJSONString().getBytes());
|
||||
config.put("MainDapp", base64Str);
|
||||
|
||||
String configString = Base64.getEncoder().encodeToString(config.toJSONString().getBytes());
|
||||
|
||||
// 将config 存入数据库
|
||||
if (configService.getConfig(project) == null) {
|
||||
configService.setConfig(project, configString);
|
||||
} else {
|
||||
// update
|
||||
configService.updateConfig(project, configString);
|
||||
}
|
||||
return BaseResult.success(200, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return BaseResult.err("error.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/updatePass")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "修改密码", response = UpdatePasswdReq.class)
|
||||
public BaseResult updatePass(@RequestBody UpdatePasswdReq req){
|
||||
return BaseResult.success(200, userService.updatePassword(req.getUsername(), req.getPassword(), req.getOldPassword()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.mhhy.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.ProjectConfigEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.model.req.CustomerReq;
|
||||
import com.mhhy.model.req.FindUserReq;
|
||||
import com.mhhy.model.req.ProjectReq;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
import com.mhhy.service.GroupService;
|
||||
import com.mhhy.service.ProjectConfigService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/project")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Setter(value = AccessLevel.PRIVATE, onMethod_ = @Autowired)
|
||||
public class ProjectController {
|
||||
|
||||
@Autowired
|
||||
ProjectConfigService projectService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "add", response = LoginResp.class)
|
||||
public BaseResult add(@RequestBody ProjectReq req) {
|
||||
|
||||
if (!projectService.setConfig(req.getProject(), req.getConfig(), req.getConfig2()) ) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "success.");
|
||||
}
|
||||
|
||||
// @PostMapping("/list")
|
||||
// @CrossOrigin(origins = "*")
|
||||
// @ApiOperation(value = "list", response = LoginResp.class)
|
||||
// public BaseResult list(@RequestBody ProjectReq req) {
|
||||
//
|
||||
// List list = projectService.listConfig();
|
||||
//
|
||||
// return BaseResult.success(200, list);
|
||||
// }
|
||||
|
||||
@PostMapping("/list")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "list", response = LoginResp.class)
|
||||
public BaseResult list(@RequestBody FindUserReq req) {
|
||||
|
||||
int page = req.getPage();
|
||||
int limit = req.getLimit();
|
||||
|
||||
List<ProjectConfigEntity> list = projectService.listProject(page, limit);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("list", list);
|
||||
|
||||
int count = projectService.count();
|
||||
result.put("count", count);
|
||||
/*int fixPage = 0;
|
||||
if (count%limit > 0) {
|
||||
fixPage ++;
|
||||
}
|
||||
result.put("page", count/limit + fixPage);*/
|
||||
result.put("page", page);
|
||||
|
||||
return BaseResult.success(200, result);
|
||||
}
|
||||
|
||||
@PostMapping("/update1")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "del", response = LoginResp.class)
|
||||
public BaseResult updateConfig1(@RequestBody ProjectReq req) {
|
||||
|
||||
if (!projectService.updateConfig(req.getProject(), req.getConfig())){
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "login success.");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/update2")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "del", response = LoginResp.class)
|
||||
public BaseResult updateConfig2(@RequestBody ProjectReq req) {
|
||||
|
||||
if (!projectService.updateConfig2(req.getProject(), req.getConfig())){
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "login success.");
|
||||
}
|
||||
|
||||
@PostMapping("/del")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "del", response = LoginResp.class)
|
||||
public BaseResult deleteConfig(@RequestBody ProjectReq req) {
|
||||
|
||||
if (!projectService.deleteConfig(req.getProject())) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, "delete success.");
|
||||
}
|
||||
|
||||
@PostMapping("/getDapp")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "getDapp", response = LoginResp.class)
|
||||
public BaseResult getDapp(@RequestBody ProjectReq req) {
|
||||
|
||||
String dappInfo = projectService.getDappInfo(req.getProject());
|
||||
if (dappInfo == null) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, dappInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/query-config")
|
||||
@CrossOrigin(origins = "*")
|
||||
@ApiOperation(value = "queryConfig", response = LoginResp.class)
|
||||
public BaseResult queryConfig(@RequestBody ProjectReq req) {
|
||||
List<ProjectConfigEntity> projectConfigEntities;
|
||||
if (!StringUtils.isEmpty(req.getProject())){
|
||||
projectConfigEntities = projectService.listProjectConfig(req.getProject());
|
||||
}else {
|
||||
return BaseResult.err("project not exist.");
|
||||
}
|
||||
if (projectConfigEntities == null) {
|
||||
return BaseResult.err("failed.");
|
||||
}
|
||||
|
||||
return BaseResult.success(200, projectConfigEntities);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mhhy.enums;
|
||||
|
||||
public interface BaseEnum {
|
||||
|
||||
int getEnumCode();
|
||||
|
||||
//BaseEnum valueOf(int enumCode);
|
||||
|
||||
default String i18nKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mhhy.enums;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EnumTypeConverterFactory implements ConverterFactory<String, BaseEnum> {
|
||||
|
||||
private static final Map<Class, Converter> converterMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public <T extends BaseEnum> Converter<String, T> getConverter(Class<T> targetType) {
|
||||
Converter result = converterMap.get(targetType);
|
||||
if (result == null) {
|
||||
result = new IntegerStrToEnum<T>(targetType);
|
||||
converterMap.put(targetType, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private class IntegerStrToEnum<T extends BaseEnum> implements Converter<String, T> {
|
||||
private final Class<T> enumType;
|
||||
private Map<String, T> enumMap = new HashMap<>();
|
||||
|
||||
public IntegerStrToEnum(Class<T> enumType) {
|
||||
this.enumType = enumType;
|
||||
T[] enums = enumType.getEnumConstants();
|
||||
for (T e : enums) {
|
||||
enumMap.put(e.getEnumCode() + "", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T convert(String source) {
|
||||
T result = enumMap.get(source);
|
||||
if (result == null) {
|
||||
//throw new IllegalArgumentException("No element matches " + source);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mhhy.enums;
|
||||
|
||||
public enum ResultCodeEnum {
|
||||
|
||||
SUCCESS(0, "success"),//请求成功
|
||||
BAD_REQUEST(400, "错误请求"),//错误请求
|
||||
UN_AUTHORIZATION(401, "请登录"),//该钱包已在其他设备登录
|
||||
NOT_REPEAT_SEND_SMS(402, "请勿重发短信"),
|
||||
SERVER_EXCEPTION(500, "网络异常"),//网络异常
|
||||
BALANCE_NOT_ENOUGH(600, "余额不足"),//网络异常
|
||||
PAY_ORDER(700, "支付失败"),//网络异常
|
||||
DATA_ORDER(800, "数据异常"),//网络异常
|
||||
|
||||
ACCOUNT_ALREADY(1000, "user already exist"),
|
||||
PASSWORD_ERROR(1001, "wrong password"),
|
||||
ACCOUNT_NOT_EXIST(1002, "User not exist"),
|
||||
IM_REGISTER_FAILED(1003, "register im account failed."),
|
||||
DB_ERROR(1004, "db error."),
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
private final int code;
|
||||
private final String remark;
|
||||
|
||||
ResultCodeEnum(int code, String remark) {
|
||||
this.code = code;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mhhy.enums;
|
||||
|
||||
public enum UserStateEnum {
|
||||
|
||||
ENABLE(0, "未启用"),
|
||||
NORMAL(1, "正常"),
|
||||
DISABLE(2, "禁用")
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
private final int code;
|
||||
private final String remark;
|
||||
|
||||
UserStateEnum(int code, String remark) {
|
||||
this.code = code;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mhhy.enums;
|
||||
|
||||
public enum UserTypeEnum {
|
||||
|
||||
ADMIN(1, "管理员"),
|
||||
CUSTOMER(2, "客服"),
|
||||
NORMAL(3, "普通用户")
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
private final int code;
|
||||
private final String remark;
|
||||
|
||||
UserTypeEnum(int code, String remark) {
|
||||
this.code = code;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mhhy.exception;
|
||||
|
||||
public class CheckException extends RuntimeException {
|
||||
public CheckException() {
|
||||
}
|
||||
|
||||
public CheckException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CheckException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CheckException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CheckException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.mhhy.exception;
|
||||
|
||||
|
||||
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.enums.ResultCodeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class ErrorHandler {
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public BaseResult<?> handleRuntimeException(RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
ResultCodeEnum resultCodeEnum = ResultCodeEnum.SERVER_EXCEPTION;
|
||||
return new BaseResult<>(resultCodeEnum.getCode(), resultCodeEnum.getRemark());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(OdcException.class)
|
||||
public BaseResult<?> handleException(OdcException e) {
|
||||
//log.debug("{}: {}, {}", e.getCode(), e.getResultCodeEnum().getRemark(), e.getOtherInfo());
|
||||
//String resultEnumMsg = MessageUtil.getResultMsg(e.getCode());
|
||||
BaseResult<Map<String, ?>> result = new BaseResult<>(e.getCode(), e.getMessage());
|
||||
result.setData(e.getOtherInfo());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public BaseResult<?> handleException(IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
int code = ResultCodeEnum.BAD_REQUEST.getCode();
|
||||
return new BaseResult<>(code, e.getMessage());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public BaseResult<?> handleException(MethodArgumentNotValidException e) {
|
||||
e.printStackTrace();
|
||||
int code = ResultCodeEnum.BAD_REQUEST.getCode();
|
||||
return new BaseResult<>(code, e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mhhy.exception;
|
||||
|
||||
import com.mhhy.enums.ResultCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class OdcException extends RuntimeException {
|
||||
|
||||
private int code;
|
||||
|
||||
private ResultCodeEnum resultCodeEnum;
|
||||
|
||||
private Map<String, ?> otherInfo;
|
||||
|
||||
public OdcException(ResultCodeEnum codeEnum) {
|
||||
super(codeEnum.getRemark());
|
||||
code = codeEnum.getCode();
|
||||
resultCodeEnum = codeEnum;
|
||||
}
|
||||
|
||||
public OdcException(ResultCodeEnum codeEnum, Map<String, ?> otherInfo) {
|
||||
super(codeEnum.getRemark());
|
||||
this.code = codeEnum.getCode();
|
||||
this.otherInfo = otherInfo;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ResultCodeEnum getResultCodeEnum() {
|
||||
return resultCodeEnum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mhhy.interceptor;
|
||||
|
||||
|
||||
|
||||
import com.mhhy.annotation.Login;
|
||||
import com.mhhy.util.RedisUtil;
|
||||
import com.mhhy.util.RequestUtil;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author zcw
|
||||
* @version 1.0
|
||||
* @date 2019/11/21 21:53
|
||||
* @description 授权认证
|
||||
*/
|
||||
@Log4j2
|
||||
@Configuration
|
||||
@Component(value = "authInterceptor")
|
||||
public class AuthInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
Login login = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
|
||||
if (login == null) {
|
||||
return true;
|
||||
}
|
||||
if (login.encrypted()) {
|
||||
return true;
|
||||
}
|
||||
//已登录的接口,限制同一个接口,每两秒最多只能调一次
|
||||
int userId = RequestUtil.getMainUserId();
|
||||
String path = request.getServletPath();
|
||||
String method = request.getMethod();
|
||||
if ("GET".equalsIgnoreCase(method)) {
|
||||
return true;
|
||||
}
|
||||
String cacheKey = String.format("vex:apiLimit:%d-%s-%s", userId, method, path);
|
||||
if (RedisUtil.setNx(cacheKey, "0")) {
|
||||
RedisUtil.expire(cacheKey, 2);
|
||||
return true;
|
||||
}
|
||||
throw new IllegalArgumentException("请勿重复点击");//请勿重复点击 Please do not click repeatedly
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mhhy.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhhy.model.entity.AdminEntity;
|
||||
|
||||
|
||||
public interface AdminMapper extends BaseMapper<AdminEntity> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.mhhy.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhhy.model.entity.AppVersionEntity;
|
||||
|
||||
public interface AppVersionEntityMapper extends BaseMapper<AppVersionEntity> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mhhy.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.model.entity.ProjectConfigEntity;
|
||||
|
||||
public interface CustomerMapper extends BaseMapper<CustomerEntity> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mhhy.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.model.entity.GroupEntity;
|
||||
|
||||
public interface GroupMapper extends BaseMapper<GroupEntity> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.mhhy.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhhy.model.entity.ProjectConfigEntity;
|
||||
|
||||
public interface ProjectConfigMapper extends BaseMapper<ProjectConfigEntity> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.mhhy.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
public interface UserMapper extends BaseMapper<UserEntity> {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mhhy.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("t_admin")
|
||||
public class AdminEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private int level;
|
||||
|
||||
private int state;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.mhhy.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("t_app_version")
|
||||
public class AppVersionEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("apk下载链接")
|
||||
private String apkUrl;
|
||||
|
||||
@ApiModelProperty("是否强制更新e否1是")
|
||||
private Integer updateVersion;
|
||||
|
||||
@ApiModelProperty("安卓版本号")
|
||||
private Integer androidCode;
|
||||
|
||||
@ApiModelProperty("android版本号名称")
|
||||
private String androidVersion;
|
||||
|
||||
@ApiModelProperty("ios版本号")
|
||||
private Integer iosCode;
|
||||
|
||||
@ApiModelProperty("描述")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("ios版本号名称")
|
||||
private String iosVersion;
|
||||
|
||||
@ApiModelProperty("代理商用户==username")
|
||||
private String user;
|
||||
|
||||
@ApiModelProperty("1:管理员\\r\\n2:代理商\\r\\n3:普通用户")
|
||||
private Integer state;
|
||||
|
||||
@ApiModelProperty("0:正常\\r\\n1:禁用")
|
||||
private Integer isShow;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("ios下载链接")
|
||||
private String iosUrl;
|
||||
@ApiModelProperty("安卓是否显示更新")
|
||||
private Integer androidShow;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mhhy.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("t_customer")
|
||||
public class CustomerEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String osnId;
|
||||
|
||||
private String portrait;
|
||||
|
||||
private String project;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mhhy.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("t_group")
|
||||
public class GroupEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String osnId;
|
||||
|
||||
private String portrait;
|
||||
|
||||
private String project;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mhhy.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("t_config")
|
||||
public class ProjectConfigEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String project;
|
||||
|
||||
private String config;
|
||||
|
||||
private String config2;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mhhy.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("t_user")
|
||||
public class UserEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("im id")
|
||||
private String imId;
|
||||
|
||||
@ApiModelProperty("im用户名")
|
||||
private String imUsername;
|
||||
|
||||
@ApiModelProperty("im密码")
|
||||
private String imPwd;
|
||||
|
||||
@ApiModelProperty("im node")
|
||||
private String imNode;
|
||||
|
||||
@ApiModelProperty("nick name")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty("1:管理员\\r\\n2:代理商\\r\\n3:普通用户")
|
||||
private Integer state;
|
||||
|
||||
@ApiModelProperty("0:未启用\\r\\n1:正常\\r\\n2:禁用")
|
||||
private Integer type;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private String project;
|
||||
|
||||
private String portrait;
|
||||
|
||||
|
||||
public boolean isSetPassword() {
|
||||
if (password == null) {
|
||||
return false;
|
||||
}
|
||||
if (password.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateGroupReq {
|
||||
String user;
|
||||
String phoneOrEmail;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CustomerReq {
|
||||
|
||||
private String project;
|
||||
|
||||
private String name;
|
||||
|
||||
private String osnId;
|
||||
|
||||
private String portrait;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import com.ospn.command.CmdDappLogin;
|
||||
import com.ospn.command.CmdGetServerInfo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DappRequest {
|
||||
public String command;
|
||||
public String user;
|
||||
public String sign;
|
||||
public String hash;
|
||||
public long random;
|
||||
|
||||
public CmdDappLogin getCmdDappLogin(String session){
|
||||
CmdDappLogin cmd = new CmdDappLogin();
|
||||
cmd.command = command;
|
||||
cmd.user = user;
|
||||
cmd.sign = sign;
|
||||
cmd.hash = hash;
|
||||
cmd.session = session;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public CmdGetServerInfo getCmdGetServerInfo(String session){
|
||||
CmdGetServerInfo cmd = new CmdGetServerInfo();
|
||||
cmd.command = command;
|
||||
cmd.user = user;
|
||||
cmd.random = random;
|
||||
cmd.session = session;
|
||||
return cmd;
|
||||
}
|
||||
public CmdGetServerInfo getCmdGetServerInfo(){
|
||||
CmdGetServerInfo cmd = new CmdGetServerInfo();
|
||||
cmd.command = command;
|
||||
cmd.user = user;
|
||||
cmd.random = random;
|
||||
cmd.session = null;
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FindAppVersionReq {
|
||||
|
||||
private int page;
|
||||
|
||||
private int limit;
|
||||
|
||||
private String user;
|
||||
|
||||
private Integer id;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FindUserReq {
|
||||
|
||||
private int page;
|
||||
|
||||
private int limit;
|
||||
|
||||
private String osnId;
|
||||
|
||||
private String project;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GroupReq {
|
||||
|
||||
private String project;
|
||||
|
||||
private String name;
|
||||
|
||||
private String osnId;
|
||||
|
||||
private String portrait;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LoginReq {
|
||||
|
||||
private String username;
|
||||
|
||||
private String account;
|
||||
|
||||
private String password;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String smsCode;
|
||||
|
||||
private String picCode;
|
||||
|
||||
private String data;
|
||||
|
||||
private String user;
|
||||
|
||||
private String project;
|
||||
|
||||
private String invite;
|
||||
|
||||
private String url;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NodeRegisterReq {
|
||||
|
||||
private String data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProjectReq {
|
||||
|
||||
private String project;
|
||||
|
||||
private String config;
|
||||
|
||||
private String config2;
|
||||
|
||||
private String portrait;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RegisterReq {
|
||||
|
||||
private String username;
|
||||
|
||||
private String account;
|
||||
|
||||
private String password;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String smsCode;
|
||||
|
||||
private String picCode;
|
||||
|
||||
private String data;
|
||||
|
||||
private String key;
|
||||
|
||||
private int level;
|
||||
private String project;
|
||||
|
||||
public RegisterReq() {
|
||||
|
||||
}
|
||||
|
||||
public RegisterReq(String param) {
|
||||
try {
|
||||
JSONObject json = JSONObject.parseObject(param);
|
||||
username = json.getString("username");
|
||||
password = json.getString("password");
|
||||
nickName = json.getString("nickName");
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ReqBase {
|
||||
private String data;
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mhhy.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdatePasswdReq {
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
private String oldPassword;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mhhy.model.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LoginResp {
|
||||
|
||||
private String token;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImInfoVer2 {
|
||||
|
||||
public List<OsnUser> osn_users;
|
||||
public String service_id;
|
||||
public boolean password = true;
|
||||
public JSONObject json;
|
||||
|
||||
public ImInfoVer2(UserEntity user, JSONObject jsonObject, String sid) {
|
||||
json = jsonObject;
|
||||
service_id = sid;
|
||||
osn_users = new ArrayList<>();
|
||||
OsnUser osnUser = new OsnUser(user);
|
||||
osn_users.add(osnUser);
|
||||
}
|
||||
|
||||
/*"Token": "b568c30a-7751-4d64-934a-2286ca1139b1",
|
||||
"Expires": "1694164789",
|
||||
"Refresh_Token": "OXiVGJp5eCQlZlb0kI6451Au3SMzVfXH",
|
||||
"Refresh_Token_Expires": "1699348789",
|
||||
|
||||
"UserInfo"
|
||||
|
||||
"ImInfo":*/
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
public class LoginResult {
|
||||
|
||||
public String Token = "b568c30a-7751-4d64-934a-2286ca1139b1";
|
||||
public String Expires = "1694164789";
|
||||
public String Refresh_Token = "OXiVGJp5eCQlZlb0kI6451Au3SMzVfXH";
|
||||
public String Refresh_Token_Expires = "1699348789";
|
||||
public UserInfoVer2 UserInfo;
|
||||
public ImInfoVer2 ImInfo;
|
||||
|
||||
public LoginResult(UserEntity user, JSONObject config, String sid) {
|
||||
UserInfo = new UserInfoVer2(user);
|
||||
ImInfo = new ImInfoVer2(user, config, sid);
|
||||
}
|
||||
|
||||
public JSONObject toJson() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("Token", Token);
|
||||
json.put("Expires", Expires);
|
||||
json.put("Refresh_Token", Refresh_Token);
|
||||
json.put("Refresh_Token_Expires", Refresh_Token_Expires);
|
||||
json.put("UserInfo", UserInfo);
|
||||
json.put("ImInfo", ImInfo);
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NodeGetUserData {
|
||||
private String user;
|
||||
|
||||
public NodeGetUserData(JSONObject json){
|
||||
user = json.getString("user");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class NodeRegisterData {
|
||||
public String IP;
|
||||
public String region;
|
||||
|
||||
public NodeRegisterData(JSONObject json){
|
||||
IP = json.getString("IP");
|
||||
region = json.getString("region");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class NodeSetUsingData {
|
||||
private String user;
|
||||
private String node;
|
||||
private int state = 0;
|
||||
|
||||
public NodeSetUsingData(JSONObject json){
|
||||
user = json.getString("user");
|
||||
node = json.getString("node");
|
||||
state = json.getIntValue("state");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
public class OsnUser {
|
||||
public String osn_id; //: "OSNUiHLZ1XaDcV6MjarXvQUoo6hSzJYBFGUbJ6AXbW3vb8uNDL9LLtgk72c9cidF9V152q3BjwG4YN",
|
||||
public String osn_username; //: "bd9a4aa9774220ad4c0c",
|
||||
public String osn_password; //: "VER2-VK0MHcCAQEEIAABdS7Igb/rV9A+NiHujrpgl900yQ25SPGuYHDRqde/oAoGCCqGSM49AwEHoUQDQgAE1fPNCotCuh49lYrjHLqnMhx3d6f3IG+eM0WEIwNVrjszmG2ARcCPXOGt7PFXdZQdEwxQdfHbspIiYpNH86in+Q==-MHcCAQEEIE3B3LONlmxLjMy3ofwAo4qpcdCHzyMbL6+XndTEoBrMoAoGCCqGSM49AwEHoUQDQgAEKbtW4NBM64a68V48Jp9fR85WNzVebo7o3ldrV1hGRBoX4qO+DPulHxjKDKNbQOqHH+ihU/+yrFh1PQa+XcE5ng==",
|
||||
public String userId; //: "f3739c0075e0d176bce405f017eec587",
|
||||
public String corpName; //: null,
|
||||
public boolean admin = false; //: false,
|
||||
public String osn_node; //: "39.100.133.144",
|
||||
public String nickName; //: null,
|
||||
public String cornet; //: null,
|
||||
public String headUrl; //": null,
|
||||
public boolean def = true; //: true
|
||||
|
||||
public OsnUser(UserEntity user) {
|
||||
osn_id = user.getImId();
|
||||
osn_username = user.getUsername();
|
||||
osn_password = user.getImPwd();
|
||||
userId = user.getId().toString();
|
||||
osn_node = user.getImNode();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ServiceInfo {
|
||||
int id;
|
||||
|
||||
String iconUrl;
|
||||
|
||||
String serviceName;
|
||||
|
||||
String url;
|
||||
|
||||
String serviceRemark;
|
||||
|
||||
String appRemark;
|
||||
|
||||
String appIntroduction;
|
||||
|
||||
String createTime;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserCreateOrderData {
|
||||
int lifecycle;
|
||||
String pay_id;
|
||||
|
||||
public UserCreateOrderData(JSONObject json){
|
||||
lifecycle = json.getIntValue("lifecycle");
|
||||
pay_id = json.getString("payId");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserInfoVer2 {
|
||||
|
||||
public String F_UserId;
|
||||
public String F_Account;
|
||||
public String F_EnCode; //": null,
|
||||
public String F_RealName; //": null,
|
||||
public String F_HeadIcon; //": null,
|
||||
public String F_Mobile = ""; //
|
||||
public String F_Email; //": null,
|
||||
public String F_WeChat; //": null,
|
||||
public String F_Gender; //": null,
|
||||
public String F_Description; //": null,
|
||||
public String F_Company; //": null,
|
||||
public List<String> F_Department = new ArrayList<>(); //": [],
|
||||
public List<String> F_Role = new ArrayList<>(); //": []
|
||||
|
||||
public UserInfoVer2(UserEntity user) {
|
||||
F_UserId = user.getId().toString();
|
||||
F_Account = user.getUsername();
|
||||
}
|
||||
|
||||
public JSONObject toJson() {
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("F_UserId", F_UserId);
|
||||
json.put("F_Account", F_Account);
|
||||
json.put("F_EnCode", F_EnCode);
|
||||
json.put("F_RealName", F_RealName);
|
||||
json.put("F_HeadIcon", F_HeadIcon);
|
||||
json.put("F_Mobile", F_Mobile);
|
||||
json.put("F_Email", F_Email);
|
||||
json.put("F_WeChat", F_WeChat);
|
||||
json.put("F_Gender", F_Gender);
|
||||
json.put("F_Description", F_Description);
|
||||
json.put("F_Company", F_Company);
|
||||
json.put("F_Department", F_Department);
|
||||
json.put("F_Role", F_Role);
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserQueryOrderData {
|
||||
String orderNo;
|
||||
String user;
|
||||
|
||||
public UserQueryOrderData(JSONObject json) {
|
||||
|
||||
orderNo = json.getString("orderNo");
|
||||
user = json.getString("user");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mhhy.model.struct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserQueryProductData {
|
||||
String user;
|
||||
|
||||
public UserQueryProductData(JSONObject json) {
|
||||
user = json.getString("user");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mhhy.resolver;
|
||||
|
||||
|
||||
import com.mhhy.annotation.Login;
|
||||
import com.mhhy.util.CodecUtil;
|
||||
import com.mhhy.util.JsonUtil;
|
||||
import com.mhhy.util.StreamUtil;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
@Component
|
||||
public class DecodeArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
Login login = parameter.getMethod().getAnnotation(Login.class);
|
||||
return login != null && login.encrypted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
Class<?>[] params = parameter.getMethod().getParameterTypes();
|
||||
if (params.length != 1) {
|
||||
throw new RuntimeException("后台接口参数异常");
|
||||
}
|
||||
Class<?> targetClass = params[0];
|
||||
String body = CodecUtil.decodeURL(StreamUtil.getString(((ServletWebRequest) webRequest).getRequest().getInputStream()));
|
||||
if (body == null || body.trim().length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//todo aes解密
|
||||
return JsonUtil.fromJson(body, targetClass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.AdminEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
public interface AdminService extends IService<AdminEntity> {
|
||||
|
||||
boolean createAdmin(String username, String password);
|
||||
|
||||
boolean createCustomer(String username, String password);
|
||||
|
||||
AdminEntity findUser(String username);
|
||||
|
||||
boolean updatePassword(String username, String password);
|
||||
|
||||
boolean updateState(String username, int state);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhhy.model.entity.AppVersionEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AppVersionEntityService extends IService<AppVersionEntity> {
|
||||
|
||||
|
||||
List<AppVersionEntity> listAppVersionAll();
|
||||
|
||||
AppVersionEntity getUser();
|
||||
|
||||
boolean updateAppVersion(AppVersionEntity appVersionEntity);
|
||||
|
||||
List<AppVersionEntity> listAppVersion(int page, int limit);
|
||||
|
||||
List<AppVersionEntity> listAppVersionUser(int page, int limit, String user);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.model.entity.ProjectConfigEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomerService extends IService<CustomerEntity> {
|
||||
|
||||
// 增
|
||||
boolean addObj(String name, String portrait, String osnId, String project);
|
||||
|
||||
// 查
|
||||
List<CustomerEntity> listAll();
|
||||
List<CustomerEntity> listByProject(String project);
|
||||
|
||||
// 改
|
||||
|
||||
// 删
|
||||
boolean deleteObj(String osnId, String project);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.model.entity.GroupEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GroupService extends IService<GroupEntity> {
|
||||
|
||||
// 增
|
||||
boolean addObj(String name, String portrait, String osnId, String project);
|
||||
|
||||
// 查
|
||||
List<GroupEntity> listAll();
|
||||
List<GroupEntity> listByProject(String project);
|
||||
|
||||
// 改
|
||||
|
||||
// 删
|
||||
boolean deleteObj(String osnId, String project);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.model.req.LoginReq;
|
||||
import com.mhhy.model.req.RegisterReq;
|
||||
import com.mhhy.model.resp.LoginResp;
|
||||
|
||||
public interface LoginService {
|
||||
|
||||
BaseResult register(RegisterReq registerReq);
|
||||
BaseResult register2(RegisterReq registerReq);
|
||||
BaseResult register4(RegisterReq registerReq, String key);
|
||||
BaseResult register5(RegisterReq registerReq, String key, String UserPwd, String owner2);
|
||||
|
||||
String[] createAccount();
|
||||
|
||||
JSONObject register3(RegisterReq registerReq);
|
||||
UserEntity register6(String imId, String owner2, String project);
|
||||
|
||||
BaseResult login(LoginReq loginReq);
|
||||
|
||||
BaseResult getChallenge(String userName);
|
||||
|
||||
JSONObject getConfig();
|
||||
|
||||
String createGroup(String groupName, String owner);
|
||||
|
||||
String getHostIp();
|
||||
|
||||
boolean disableOrEnableUser(String osnId, boolean enable);
|
||||
|
||||
String getRegisterKey();
|
||||
}
|
||||
@@ -0,0 +1,686 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.model.entity.GroupEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.ospn.command.CmdDappLogin;
|
||||
import com.ospn.command.CmdReDappLogin;
|
||||
import com.ospn.common.OsnServer;
|
||||
import com.ospn.common.OsnUtils;
|
||||
import com.ospn.core.ILTPEvent;
|
||||
import com.ospn.core.LTPData;
|
||||
import com.ospn.utils.CryptUtils;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import static com.ospn.utils.CryptUtils.makeMessage;
|
||||
import static com.ospn.utils.CryptUtils.takeMessage;
|
||||
|
||||
@Service
|
||||
public class LtpServer extends OsnServer implements ILTPEvent {
|
||||
|
||||
//@Autowired
|
||||
//public IDeviceService deviceService;
|
||||
//@Autowired
|
||||
//private MyJPushClient myJPushClient;
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
GroupService groupService;
|
||||
|
||||
@Autowired
|
||||
CustomerService customerService;
|
||||
|
||||
|
||||
public static LTPData ltpData;
|
||||
|
||||
public static String custormer;
|
||||
|
||||
static RunnerThread runner;
|
||||
|
||||
private ConcurrentHashMap<String, List<String>> pushDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
static String password="password123";
|
||||
|
||||
|
||||
public LtpServer(){
|
||||
init();
|
||||
}
|
||||
|
||||
void init(){
|
||||
|
||||
if (ltpData != null){
|
||||
return;
|
||||
}
|
||||
ltpData = new LTPData();
|
||||
|
||||
try {
|
||||
|
||||
InputStream in = new FileInputStream("ospn.properties");
|
||||
Properties prop = new Properties();
|
||||
prop.load(in);
|
||||
|
||||
custormer = prop.getProperty("customer");
|
||||
System.out.println("[custormer]" + custormer);
|
||||
|
||||
ltpData.init(prop, password,this);
|
||||
in.close();
|
||||
|
||||
prop.put("appID", ltpData.apps.osnID);
|
||||
String encPrivateKey = OsnUtils.aesEncrypt(ltpData.apps.osnKey, password);
|
||||
prop.put("appKey", encPrivateKey);
|
||||
|
||||
FileOutputStream oFile = new FileOutputStream("ospn.properties", false);
|
||||
prop.store(oFile, "Comments");
|
||||
|
||||
oFile.close();
|
||||
|
||||
}catch (Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getAppId(){
|
||||
if (ltpData == null){
|
||||
init();
|
||||
}
|
||||
if (ltpData == null){
|
||||
return null;
|
||||
}
|
||||
return ltpData.apps.osnID;
|
||||
}
|
||||
|
||||
public JSONObject makeResult(String to, JSONObject data){
|
||||
|
||||
try {
|
||||
JSONObject json = CryptUtils.makeMessage(
|
||||
"Message",
|
||||
ltpData.apps.osnID,
|
||||
to,
|
||||
data,
|
||||
ltpData.apps.osnKey,
|
||||
(JSONObject)null);
|
||||
return json;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new JSONObject();
|
||||
}
|
||||
|
||||
public void sendCommand(String command, String groupID, JSONObject json){
|
||||
|
||||
// 先扔队列里
|
||||
if (command.equalsIgnoreCase("SystemNotify")) {
|
||||
SendCommandInfo info = new SendCommandInfo(command, groupID, json);
|
||||
push(info);
|
||||
} else {
|
||||
if (ltpData != null){
|
||||
ltpData.sendJson(command, groupID, json);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendMessage(String to, JSONObject json){
|
||||
if (ltpData != null){
|
||||
ltpData.sendMessage(to, json);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendNotice2UserByAddBalance(String to, long balance, String txid, JSONObject json){
|
||||
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("type", "text");
|
||||
float bal1 = balance;
|
||||
bal1 = bal1 / 100;
|
||||
|
||||
String coin = "";
|
||||
if (json != null) {
|
||||
if (json.containsKey("coinType")) {
|
||||
coin = json.getString("coinType") + " ";
|
||||
}
|
||||
}
|
||||
|
||||
String text = "[DM wallet test system notice]\r\n" +
|
||||
"Account balance changes, receive " + coin +
|
||||
String.format("%.2f.\r\n", bal1) +
|
||||
"txid:" + txid;
|
||||
content.put("data", text);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("content", content);
|
||||
|
||||
// 扔队列里去
|
||||
SendCommandInfo info = new SendCommandInfo("Message", to, data);
|
||||
push(info);
|
||||
|
||||
/*if (ltpData != null){
|
||||
ltpData.sendMessage(to, data);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void sendNotice2UserBySubBalance(String to, long balance, String txid, JSONObject json){
|
||||
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("type", "text");
|
||||
float bal1 = balance;
|
||||
bal1 = bal1 / 100;
|
||||
|
||||
String coin = "";
|
||||
if (json != null) {
|
||||
if (json.containsKey("coinType")) {
|
||||
coin = json.getString("coinType") + " ";
|
||||
}
|
||||
}
|
||||
|
||||
String text = "[DM wallet test system notice]\r\n" +
|
||||
"Account balance changes, send " + coin +
|
||||
String.format("%.2f.\r\n", bal1) +
|
||||
"txid:" + txid;
|
||||
content.put("data", text);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("content", content);
|
||||
|
||||
// 扔队列里去
|
||||
SendCommandInfo info = new SendCommandInfo("Message", to, data);
|
||||
push(info);
|
||||
|
||||
/*if (ltpData != null){
|
||||
ltpData.sendMessage(to, data);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void sendNotice2UserByWithdrawal(String to){
|
||||
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("type", "text");
|
||||
String text = "[J-Talking system notice]\r\n" +
|
||||
"Withdrawal success.";
|
||||
content.put("data", text);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("content", content);
|
||||
|
||||
if (ltpData != null){
|
||||
ltpData.sendMessage(to, data);
|
||||
}
|
||||
}
|
||||
|
||||
public void getUserInfo(String osnID) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("command", "GetUserInfo");
|
||||
json.put("from", this.ltpData.apps.osnID);
|
||||
json.put("to", osnID);
|
||||
//System.out.println(json.toString()+"JSONsend");
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
// 扔队列里去
|
||||
SendCommandInfo info = new SendCommandInfo("GetUserInfo", osnID, data);
|
||||
push(info);
|
||||
|
||||
// ltpData.sendJson(json);
|
||||
}
|
||||
|
||||
public void getGroupInfo(String osnID) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("command", "GetUserInfo");
|
||||
json.put("from", this.ltpData.apps.osnID);
|
||||
json.put("to", osnID);
|
||||
|
||||
//System.out.println(json.toString()+"JSONsend");
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
// 扔队列里去
|
||||
SendCommandInfo info = new SendCommandInfo("GetGroupInfo", osnID, data);
|
||||
push(info);
|
||||
|
||||
// ltpData.sendJson(json);
|
||||
}
|
||||
|
||||
public boolean login(CmdDappLogin cmd){
|
||||
CmdReDappLogin cmdRe = ltpData.login(cmd);
|
||||
|
||||
if (cmdRe.errCode == null){
|
||||
return false;
|
||||
}
|
||||
if (!cmdRe.errCode.equalsIgnoreCase("0:success")){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDappInfo(){
|
||||
JSONObject content = ltpData.dappInfo.toClientJson(ltpData.apps.osnKey);
|
||||
if (content == null){
|
||||
return "";
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
public void push(SendCommandInfo data){
|
||||
if (runner == null) {
|
||||
runner = new RunnerThread();
|
||||
runner.start();
|
||||
}
|
||||
runner.push(data);
|
||||
}
|
||||
|
||||
void sendNotice(JSONObject json){
|
||||
System.out.println("[sendNotice] send notice : " + json);
|
||||
String groupId = json.getString("groupID");
|
||||
if (groupId == null){
|
||||
return;
|
||||
}
|
||||
System.out.println("[sendNotice] sendCommand");
|
||||
sendCommand("SystemNotify", groupId, json);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleMessage(ChannelHandlerContext channelHandlerContext, JSONObject jsonObject) {
|
||||
|
||||
//System.out.println("[LtpServer::handleMessage] begin. " + jsonObject);
|
||||
|
||||
System.out.println("----------------handleMessage---------------------:"+jsonObject);
|
||||
// 处理收到的消息
|
||||
if (jsonObject == null){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String command = jsonObject.getString("command");
|
||||
String to = jsonObject.getString("to");
|
||||
if (command == null || to == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!to.equalsIgnoreCase(ltpData.apps.osnID)){
|
||||
System.out.println("[LtpServer::handleMessage] error, to is " + to);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//System.out.println("[handleMessage] begin!!!!!!");
|
||||
|
||||
if(command.equalsIgnoreCase("UserInfo")){
|
||||
|
||||
handleUserInfo(jsonObject);
|
||||
|
||||
} else if(command.equalsIgnoreCase("GroupInfo")){
|
||||
|
||||
handleGroupInfo(jsonObject);
|
||||
|
||||
} else if(command.equalsIgnoreCase("Message")){
|
||||
|
||||
JSONObject data = takeMessage(jsonObject);
|
||||
if(data == null) {
|
||||
return;
|
||||
}
|
||||
String command2 = data.getString("command");
|
||||
if (command2 != null) {
|
||||
if (command2.equalsIgnoreCase("PushInfo")) {
|
||||
|
||||
String user = data.getString("user");
|
||||
String type = data.getString("type");
|
||||
|
||||
List<String> cmdList = pushDataMap.get(user);
|
||||
if (cmdList == null) {
|
||||
cmdList = new ArrayList<>();
|
||||
pushDataMap.put(user, cmdList);
|
||||
}
|
||||
cmdList.add(type);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String commandID = data.getString("commandID");
|
||||
if (commandID == null){
|
||||
return;
|
||||
}
|
||||
System.out.println("commandID : " + commandID);
|
||||
String result = data.getString("result");
|
||||
if (result == null){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else if (command.equalsIgnoreCase("GetServiceInfo")){
|
||||
|
||||
String from = jsonObject.getString("from");
|
||||
if (from == null){
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject content = ltpData.dappInfo.toClientJson(ltpData.apps.osnKey);
|
||||
|
||||
System.out.println("[LtpServer::HandleMessage] dapp content : " + content);
|
||||
|
||||
JSONObject original = new JSONObject();
|
||||
original.put("id", jsonObject.getString("id"));
|
||||
|
||||
System.out.println("[LtpServer::HandleMessage] original id : " + original);
|
||||
|
||||
JSONObject returnData = makeMessage(
|
||||
"ServiceInfo",
|
||||
ltpData.apps.osnID,
|
||||
from,
|
||||
content,
|
||||
ltpData.apps.osnKey,
|
||||
original);
|
||||
|
||||
ltpData.sendJson(returnData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void pushWorker(){
|
||||
|
||||
ConcurrentHashMap<String, List<String>> tempPushMap = pushDataMap;
|
||||
System.out.println("push data map size : " + tempPushMap.size());
|
||||
|
||||
pushDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
System.out.println("push data map size : " + tempPushMap.size());
|
||||
Iterator<ConcurrentHashMap.Entry<String, List<String>>> iter = tempPushMap.entrySet().iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
ConcurrentHashMap.Entry<String, List<String>> entry = iter.next();
|
||||
// pushMessage(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handleUserInfo(JSONObject json){
|
||||
|
||||
try {
|
||||
|
||||
System.out.println("[handleUserInfo] : "+json);
|
||||
json = JSONObject.parseObject(json.getString("content"));
|
||||
/**
|
||||
* TODO : 这里处理接收到的user info 信息
|
||||
* "userID" : osn id
|
||||
* "displayName" : 昵称
|
||||
* "describes"
|
||||
* "portrait" : 头像url
|
||||
* "urlSpace" :
|
||||
* **/
|
||||
|
||||
String displayName = json.getString("displayName");
|
||||
String portrait = json.getString("portrait");
|
||||
String userId = json.getString("userID");
|
||||
|
||||
UserEntity user = userService.getUser(userId);
|
||||
if (user != null) {
|
||||
user.setNickName(displayName);
|
||||
user.setPortrait(portrait);
|
||||
|
||||
userService.updateById(user);
|
||||
}
|
||||
|
||||
CustomerEntity customerEntity = customerService.getOne(new LambdaQueryWrapper<CustomerEntity>()
|
||||
.eq(CustomerEntity::getOsnId, userId)
|
||||
);
|
||||
if (customerEntity != null) {
|
||||
customerEntity.setName( displayName );
|
||||
customerEntity.setPortrait(portrait);
|
||||
customerService.updateById(customerEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void handleGroupInfo(JSONObject json){
|
||||
|
||||
try {
|
||||
|
||||
System.out.println("[handleUserInfo] : "+json);
|
||||
json = JSONObject.parseObject(json.getString("content"));
|
||||
/**
|
||||
* TODO : 这里处理接收到的user info 信息
|
||||
* "userID" : osn id
|
||||
* "displayName" : 昵称
|
||||
* "describes"
|
||||
* "portrait" : 头像url
|
||||
* "urlSpace" :
|
||||
* **/
|
||||
|
||||
String name = json.getString("name");
|
||||
String portrait = json.getString("portrait");
|
||||
String groupId = json.getString("groupID");
|
||||
|
||||
GroupEntity groupEntity = groupService.getOne(new LambdaQueryWrapper<GroupEntity>().eq(GroupEntity::getOsnId, groupId));
|
||||
if (groupEntity != null) {
|
||||
groupEntity.setName(name);
|
||||
groupEntity.setPortrait(portrait);
|
||||
|
||||
groupService.updateById(groupEntity);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//public void pushMessage(String user, List<String> cmdList){
|
||||
//
|
||||
// // 根据device表中的vendor决定使用什么推送
|
||||
// // iphone
|
||||
// // Xiaomi 使用小米推送
|
||||
// // huawei
|
||||
// // OPPO
|
||||
// // vivo
|
||||
// // FCM 使用极光
|
||||
//
|
||||
// System.out.println("推送开始------");
|
||||
//
|
||||
// String content = "You have " +cmdList.size()+ " new message.";
|
||||
// String alias = genAlias(user);
|
||||
//
|
||||
// Device device = deviceService.getByOsnId(user);
|
||||
// if (device != null) {
|
||||
// String vendor = device.getVendor();
|
||||
// switch (vendor) {
|
||||
//
|
||||
// case "Xiaomi":
|
||||
// pushToXiaomi(alias, "new message", content);
|
||||
// break;
|
||||
//
|
||||
// case "apple":
|
||||
// pushJiguangToId(device.getDevice(), "new message", content);
|
||||
// break;
|
||||
//
|
||||
// //default:
|
||||
// // pushJiguang(alias, "new message", content);
|
||||
// // break;
|
||||
// default:
|
||||
// firebase(device.getDevice(), "new message", content);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
//void firebase(String device, String title, String content){
|
||||
// myJPushClient.sendMsgFirebase(device, title, content);
|
||||
//}
|
||||
//
|
||||
//void pushToXiaomi(String alias, String title, String content){
|
||||
//
|
||||
// Constants.useOfficial();
|
||||
// Sender sender = new Sender("6jzbNMq0oMzsXQFCuSIeYA==");
|
||||
// String messagePayload = "This is a message";
|
||||
// String description = content;
|
||||
// com.xiaomi.xmpush.server.Message message = new com.xiaomi.xmpush.server.Message.Builder()
|
||||
// .title(title)
|
||||
// .description(description).payload(messagePayload)
|
||||
// .restrictedPackageName("cn.net.shuting.sns.weiliao")
|
||||
// .notifyType(2) // 使用默认提示音提示
|
||||
// .extra(Constants.EXTRA_PARAM_NOTIFY_EFFECT, Constants.NOTIFY_LAUNCHER_ACTIVITY)
|
||||
// .build();
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// Result result = sender.sendToAlias(message, alias, 3);
|
||||
// /*Log.v("Server response: ", "MessageId: " + result.getMessageId()
|
||||
// + " ErrorCode: " + result.getErrorCode().toString()
|
||||
// + " Reason: " + result.getReason());*/
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
||||
//void pushJiguang(String alias, String title, String content){
|
||||
// // 推送数据
|
||||
// Message message = new Message();
|
||||
//
|
||||
// System.out.println("push alias : " + alias);
|
||||
//
|
||||
// message.setUserId(alias);
|
||||
//
|
||||
// message.setMessageContent(content);
|
||||
//
|
||||
// myJPushClient.sendMsg(message);
|
||||
//}
|
||||
//
|
||||
//void pushJiguangToId(String registerId, String title, String content){
|
||||
// // 推送数据
|
||||
// Message message = new Message();
|
||||
//
|
||||
// System.out.println("push alias : " + registerId);
|
||||
//
|
||||
// message.setUserId(registerId);
|
||||
//
|
||||
// message.setMessageContent(content);
|
||||
//
|
||||
// myJPushClient.sendMsgToId(message);
|
||||
//}
|
||||
|
||||
static byte[] ToMD5(String str) {
|
||||
// 加密后的16进制字符串
|
||||
String hexStr = "";
|
||||
try {
|
||||
// 此 MessageDigest 类为应用程序提供信息摘要算法的功能
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
// 转换为MD5码
|
||||
byte[] digest = md5.digest(str.getBytes("utf-8"));
|
||||
return digest;
|
||||
//hexStr = ByteUtils.toHexString(digest);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String genAlias(String user) {
|
||||
String alias = Base64.getUrlEncoder().encodeToString(ToMD5(user));
|
||||
return alias;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
class SendCommandInfo{
|
||||
String command;
|
||||
String groupID;
|
||||
JSONObject json;
|
||||
long createTime;
|
||||
|
||||
public SendCommandInfo(String command, String to, JSONObject json){
|
||||
this.command = command;
|
||||
this.groupID = to;
|
||||
this.json = json;
|
||||
createTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RunnerThread extends Thread {
|
||||
|
||||
final ConcurrentLinkedQueue<SendCommandInfo> dataList = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public RunnerThread(){
|
||||
}
|
||||
|
||||
public void push(SendCommandInfo data) {
|
||||
|
||||
dataList.offer(data);
|
||||
synchronized (dataList){
|
||||
dataList.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
|
||||
while(true){
|
||||
try{
|
||||
if(dataList.isEmpty()){
|
||||
synchronized (dataList){
|
||||
dataList.wait();
|
||||
}
|
||||
}
|
||||
SendCommandInfo data = dataList.poll();
|
||||
|
||||
try {
|
||||
long createTime = data.getCreateTime();
|
||||
if (createTime + 5000 > System.currentTimeMillis()) {
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
if (ltpData != null){
|
||||
ltpData.sendJson(data.getCommand(), data.getGroupID(), data.getJson());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
//logError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.ProjectConfigEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectConfigService extends IService<ProjectConfigEntity> {
|
||||
|
||||
JSONObject getConfig(String project);
|
||||
String getDappInfo(String project);
|
||||
|
||||
List<ProjectConfigEntity> listProjectConfig(String project);
|
||||
boolean setConfig(String project, String config);
|
||||
boolean setConfig(String project, String config, String config2);
|
||||
|
||||
List<ProjectConfigEntity> listConfig();
|
||||
|
||||
boolean updateConfig(String project, String config);
|
||||
boolean updateConfig2(String project, String config);
|
||||
|
||||
boolean deleteConfig(String project);
|
||||
|
||||
List<ProjectConfigEntity> listProject(int page, int limit);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mhhy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService extends IService<UserEntity> {
|
||||
BaseResult updatePassword(String data);
|
||||
boolean updatePassword(String username, String password, String oldPassword);
|
||||
String findUser(String username);
|
||||
UserEntity findAdmin(String username);
|
||||
UserEntity getUser(String osnId);
|
||||
|
||||
UserEntity getById(Integer id);
|
||||
|
||||
List<UserEntity> listAdmin(int page, int limit);
|
||||
List<UserEntity> listUser(int page, int limit, String project);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.mhhy.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.mapper.AdminMapper;
|
||||
import com.mhhy.mapper.UserMapper;
|
||||
import com.mhhy.model.entity.AdminEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.service.AdminService;
|
||||
import com.mhhy.service.UserService;
|
||||
import com.mhhy.util.PasswordUtil;
|
||||
import com.mhhy.util.RedisUtil;
|
||||
import com.mhhy.util.RequestUtil;
|
||||
import com.ospn.common.OsnUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("adminServer")
|
||||
public class AdminServiceImpl extends ServiceImpl<AdminMapper, AdminEntity> implements AdminService {
|
||||
|
||||
public boolean createAdmin(String username, String password) {
|
||||
AdminEntity adminEntity = findUser(username) ;
|
||||
if (adminEntity != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
adminEntity = new AdminEntity();
|
||||
adminEntity.setUsername(username);
|
||||
adminEntity.setPassword(password);
|
||||
adminEntity.setState(1);
|
||||
adminEntity.setLevel(1);
|
||||
return this.save(adminEntity);
|
||||
}
|
||||
|
||||
public boolean createCustomer(String username, String password) {
|
||||
AdminEntity adminEntity = findUser(username) ;
|
||||
if (adminEntity != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
adminEntity = new AdminEntity();
|
||||
adminEntity.setUsername(username);
|
||||
adminEntity.setPassword(password);
|
||||
adminEntity.setState(1);
|
||||
adminEntity.setLevel(2);
|
||||
return this.save(adminEntity);
|
||||
}
|
||||
|
||||
public AdminEntity findUser(String username) {
|
||||
AdminEntity user = this.getOne(new LambdaQueryWrapper<AdminEntity>()
|
||||
.eq(AdminEntity::getUsername, username));
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean updatePassword(String username, String password) {
|
||||
try {
|
||||
|
||||
AdminEntity adminEntity = findUser(username);
|
||||
if (adminEntity == null) {
|
||||
return false;
|
||||
}
|
||||
adminEntity.setPassword(password);
|
||||
return this.updateById(adminEntity);
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateState(String username, int state) {
|
||||
try {
|
||||
|
||||
AdminEntity adminEntity = findUser(username);
|
||||
if (adminEntity == null) {
|
||||
return false;
|
||||
}
|
||||
adminEntity.setState(state);
|
||||
return this.updateById(adminEntity);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mhhy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhhy.mapper.AppVersionEntityMapper;
|
||||
import com.mhhy.model.entity.AppVersionEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.service.AppVersionEntityService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AppVersionEntityServiceImpl extends ServiceImpl<AppVersionEntityMapper, AppVersionEntity> implements AppVersionEntityService {
|
||||
|
||||
|
||||
public List<AppVersionEntity> listAppVersionAll() {
|
||||
List<AppVersionEntity> list = this.list();
|
||||
return list;
|
||||
}
|
||||
|
||||
public AppVersionEntity getUser() {
|
||||
String last = " ORDER BY id DESC LIMIT 1";
|
||||
List<AppVersionEntity> list = this.list(new LambdaQueryWrapper<AppVersionEntity>()
|
||||
.last(last));
|
||||
AppVersionEntity appVersionEntity = new AppVersionEntity();
|
||||
if (list.size()>0){
|
||||
appVersionEntity = list.get(0);
|
||||
}
|
||||
return appVersionEntity;
|
||||
}
|
||||
|
||||
public boolean updateAppVersion(AppVersionEntity appVersionEntity) {
|
||||
boolean save = this.save(appVersionEntity);
|
||||
return save;
|
||||
}
|
||||
|
||||
public List<AppVersionEntity> listAppVersion(int page, int limit) {
|
||||
String last = " limit " + (page - 1)*limit + "," + limit;
|
||||
List<AppVersionEntity> list = this.list(new LambdaQueryWrapper<AppVersionEntity>()
|
||||
.eq(AppVersionEntity::getState, 2)
|
||||
.last(last));
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<AppVersionEntity> listAppVersionUser(int page, int limit, String user) {
|
||||
String last = " limit " + (page - 1)*limit + "," + limit;
|
||||
List<AppVersionEntity> list = this.list(new LambdaQueryWrapper<AppVersionEntity>()
|
||||
.eq(AppVersionEntity::getState, 2)
|
||||
.eq(AppVersionEntity::getUser,user)
|
||||
.last(last));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mhhy.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhhy.mapper.CustomerMapper;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.service.CustomerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CustomerServiceImpl
|
||||
extends ServiceImpl<CustomerMapper, CustomerEntity>
|
||||
implements CustomerService{
|
||||
|
||||
// 增
|
||||
public boolean addObj(String name, String portrait, String osnId, String project) {
|
||||
|
||||
CustomerEntity entity = new CustomerEntity();
|
||||
entity.setProject(project);
|
||||
entity.setName(name);
|
||||
entity.setOsnId(osnId);
|
||||
entity.setPortrait(portrait);
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
// 查
|
||||
public List<CustomerEntity> listAll() {
|
||||
return this.list();
|
||||
}
|
||||
|
||||
public List<CustomerEntity> listByProject(String project) {
|
||||
|
||||
try {
|
||||
|
||||
return this.list(new LambdaQueryWrapper<CustomerEntity>().eq(CustomerEntity::getProject, project));
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 改
|
||||
|
||||
// 删
|
||||
public boolean deleteObj(String osnId, String project) {
|
||||
return this.remove(new LambdaQueryWrapper<CustomerEntity>()
|
||||
.eq(CustomerEntity::getOsnId, osnId)
|
||||
.eq(CustomerEntity::getProject, project));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mhhy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhhy.mapper.GroupMapper;
|
||||
import com.mhhy.model.entity.CustomerEntity;
|
||||
import com.mhhy.model.entity.GroupEntity;
|
||||
import com.mhhy.service.GroupService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class GroupServiceImpl
|
||||
extends ServiceImpl<GroupMapper, GroupEntity>
|
||||
implements GroupService{
|
||||
|
||||
// 增
|
||||
public boolean addObj(String name, String portrait, String osnId, String project) {
|
||||
|
||||
GroupEntity entity = new GroupEntity();
|
||||
entity.setProject(project);
|
||||
entity.setName(name);
|
||||
entity.setOsnId(osnId);
|
||||
entity.setPortrait(portrait);
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
// 查
|
||||
public List<GroupEntity> listAll() {
|
||||
return this.list();
|
||||
}
|
||||
|
||||
public List<GroupEntity> listByProject(String project) {
|
||||
|
||||
try {
|
||||
|
||||
return this.list(new LambdaQueryWrapper<GroupEntity>().eq(GroupEntity::getProject, project));
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 改
|
||||
|
||||
// 删
|
||||
public boolean deleteObj(String osnId, String project) {
|
||||
return this.remove(new LambdaQueryWrapper<GroupEntity>()
|
||||
.eq(GroupEntity::getOsnId, osnId)
|
||||
.eq(GroupEntity::getProject, project));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,149 @@
|
||||
package com.mhhy.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.enums.ResultCodeEnum;
|
||||
import com.mhhy.enums.UserStateEnum;
|
||||
import com.mhhy.enums.UserTypeEnum;
|
||||
import com.mhhy.mapper.ProjectConfigMapper;
|
||||
import com.mhhy.mapper.UserMapper;
|
||||
import com.mhhy.model.entity.ProjectConfigEntity;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.model.req.LoginReq;
|
||||
import com.mhhy.model.req.RegisterReq;
|
||||
import com.mhhy.service.LoginService;
|
||||
import com.mhhy.service.LtpServer;
|
||||
import com.mhhy.service.ProjectConfigService;
|
||||
import com.mhhy.service.UserService;
|
||||
import com.mhhy.util.PasswordUtil;
|
||||
import com.mhhy.util.RandomUtil;
|
||||
import com.mhhy.util.RedisUtil;
|
||||
import com.mhhy.util.token.JwtUtil;
|
||||
import com.mysql.cj.util.Base64Decoder;
|
||||
import com.ospn.common.ECUtils;
|
||||
import com.ospn.common.OsnUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class ProjectConfigServiceImpl
|
||||
extends ServiceImpl<ProjectConfigMapper, ProjectConfigEntity>
|
||||
implements ProjectConfigService{
|
||||
|
||||
public JSONObject getConfig(String project){
|
||||
|
||||
ProjectConfigEntity entity = this.getOne(new LambdaQueryWrapper<ProjectConfigEntity>()
|
||||
.eq(ProjectConfigEntity::getProject, project));
|
||||
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
String temp = new String(Base64.getDecoder().decode(entity.getConfig()));
|
||||
if (temp == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject json = JSONObject.parseObject(temp);
|
||||
return json;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ProjectConfigEntity> listProjectConfig(String project){
|
||||
List<ProjectConfigEntity> list = this.list(new LambdaQueryWrapper<ProjectConfigEntity>()
|
||||
.eq(ProjectConfigEntity::getProject, project)
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
// 增
|
||||
public boolean setConfig(String project, String config) {
|
||||
|
||||
ProjectConfigEntity entity = new ProjectConfigEntity();
|
||||
entity.setProject(project);
|
||||
entity.setConfig(config);
|
||||
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
public boolean setConfig(String project, String config, String config2) {
|
||||
|
||||
ProjectConfigEntity entity = new ProjectConfigEntity();
|
||||
entity.setProject(project);
|
||||
entity.setConfig(config);
|
||||
entity.setConfig2(config2);
|
||||
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
// 查
|
||||
public List<ProjectConfigEntity> listConfig() {
|
||||
return this.list();
|
||||
}
|
||||
|
||||
public String getDappInfo(String project) {
|
||||
|
||||
ProjectConfigEntity entity =
|
||||
this.getOne(new LambdaQueryWrapper<ProjectConfigEntity>()
|
||||
.eq(ProjectConfigEntity::getProject, project)
|
||||
);
|
||||
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return entity.getConfig2();
|
||||
}
|
||||
|
||||
// 改
|
||||
public boolean updateConfig(String project, String config) {
|
||||
return this.update(new LambdaUpdateWrapper<ProjectConfigEntity>()
|
||||
.eq(ProjectConfigEntity::getProject,project)
|
||||
.set(ProjectConfigEntity::getConfig, config));
|
||||
}
|
||||
|
||||
public boolean updateConfig2(String project, String config) {
|
||||
return this.update(new LambdaUpdateWrapper<ProjectConfigEntity>()
|
||||
.eq(ProjectConfigEntity::getProject,project)
|
||||
.set(ProjectConfigEntity::getConfig2, config));
|
||||
}
|
||||
|
||||
// 删
|
||||
public boolean deleteConfig(String project) {
|
||||
return this.remove(new LambdaQueryWrapper<ProjectConfigEntity>().eq(ProjectConfigEntity::getProject, project));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectConfigEntity> listProject(int page, int limit) {
|
||||
String last = " limit " + (page - 1)*limit + "," + limit;
|
||||
List<ProjectConfigEntity> list = this.list(new LambdaQueryWrapper<ProjectConfigEntity>()
|
||||
.last(last));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.mhhy.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhhy.common.BaseResult;
|
||||
import com.mhhy.mapper.UserMapper;
|
||||
import com.mhhy.model.entity.UserEntity;
|
||||
import com.mhhy.service.UserService;
|
||||
import com.mhhy.util.*;
|
||||
import com.ospn.common.OsnUtils;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("userService")
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {
|
||||
@Override
|
||||
public BaseResult updatePassword(String data) {
|
||||
try {
|
||||
UserEntity user = RequestUtil.getMainUser();
|
||||
if (user == null) {
|
||||
return BaseResult.err("user not login.");
|
||||
}
|
||||
|
||||
// 获取解密key
|
||||
// 解密data
|
||||
String plaintext = getPlaintext(data, user);
|
||||
if (plaintext == null) {
|
||||
|
||||
return BaseResult.err("Communication key error.");
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(plaintext);
|
||||
if (user == null) {
|
||||
return BaseResult.err("get password error.");
|
||||
}
|
||||
|
||||
// 如果有密码,还需要输入原始密码
|
||||
if (user.isSetPassword()) {
|
||||
String oldPwd = jsonObject.getString("oldPassword");
|
||||
if (!user.getPassword().equalsIgnoreCase(oldPwd)) {
|
||||
return BaseResult.err("old password error.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String password = jsonObject.getString("password");
|
||||
|
||||
//对新密码进行加密
|
||||
byte[] sha256Str = PasswordUtil.getSHA256Str(password);
|
||||
String newPassword = PasswordUtil.encoderBase64(sha256Str);
|
||||
user.setPassword(newPassword);
|
||||
this.updateById(user);
|
||||
|
||||
return BaseResult.success();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return BaseResult.err("I do not known.");
|
||||
}
|
||||
|
||||
private String getPlaintext(String encData, UserEntity user) {
|
||||
|
||||
try {
|
||||
String key = RedisUtil.get("Communicationkey:"+user.getImId());
|
||||
System.out.println("[getPlaintext] encData:" + encData);
|
||||
System.out.println("[getPlaintext] user:" + user.getImId());
|
||||
System.out.println("[getPlaintext] key:" + key);
|
||||
String plaint = OsnUtils.aesDecrypt(encData, key);
|
||||
System.out.println("[getPlaintext] plaint:" + plaint);
|
||||
return plaint;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String findUser(String username) {
|
||||
UserEntity user = this.getOne(new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getUsername, username));
|
||||
if (user != null) {
|
||||
return user.getImId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserEntity findAdmin(String username) {
|
||||
UserEntity user = this.getOne(new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getUsername, username)
|
||||
.eq(UserEntity::getState, 2)
|
||||
);
|
||||
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
public UserEntity getUser(String osnId) {
|
||||
UserEntity user = this.getOne(new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getImId, osnId));
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public UserEntity getById(Integer id) {
|
||||
UserEntity userEntity = this.getById(id);
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
public List<UserEntity> listUser(int page, int limit, String project) {
|
||||
String last = " limit " + (page - 1)*limit + "," + limit;
|
||||
List<UserEntity> list = this.list(new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getProject, project)
|
||||
.last(last));
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserEntity> listAdmin(int page, int limit) {
|
||||
String last = " limit " + (page - 1)*limit + "," + limit;
|
||||
List<UserEntity> list = this.list(new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getState, 2)
|
||||
.last(last));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePassword(String username, String password, String oldPassword) {
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setPassword(password);
|
||||
return this.update(userEntity, new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getUsername, username).eq(UserEntity::getPassword, oldPassword));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.lang.reflect.Array;
|
||||
import java.security.Key;
|
||||
import java.security.Security;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
@Slf4j
|
||||
public class Aes128Util {
|
||||
|
||||
/**
|
||||
* 加密 模式:AES/CBC/PKCS7Padding
|
||||
* @param content 明文
|
||||
* @return 密文
|
||||
*/
|
||||
public static String AESEncode(String content, byte[] keyByte) {
|
||||
|
||||
if (keyByte.length != 32){
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] salt = new byte[keyByte.length / 2];
|
||||
byte[] encryptKey = new byte[keyByte.length / 2];
|
||||
// keybyte 分成2个128字节的byte[]
|
||||
// 前一个作为salt
|
||||
// 后一个作为key
|
||||
System.arraycopy(keyByte,0, salt, 0, keyByte.length / 2);
|
||||
System.arraycopy(keyByte,keyByte.length / 2, encryptKey, 0, keyByte.length / 2);
|
||||
|
||||
// 初始化
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
// 转化成JAVA的密钥格式
|
||||
Key key = new SecretKeySpec(encryptKey, "AES");
|
||||
try {
|
||||
// 初始化cipher
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(salt));
|
||||
byte[] encryptedText = cipher.doFinal(content.getBytes());
|
||||
|
||||
return Base64.getEncoder().encodeToString(encryptedText);
|
||||
|
||||
//return new String(Hex.encodeHex(encryptedText)).replaceAll("\r\n", "");
|
||||
} catch (Exception e) {
|
||||
log.info("AESEncode error", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
* @param content 密文
|
||||
* @return 铭文
|
||||
*/
|
||||
public static String AESDecode(String content, byte[] keyByte) {
|
||||
|
||||
if (keyByte.length != 32){
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] salt = new byte[keyByte.length / 2];
|
||||
byte[] encryptKey = new byte[keyByte.length / 2];
|
||||
// keybyte 分成2个128字节的byte[]
|
||||
// 前一个作为salt
|
||||
// 后一个作为key
|
||||
System.arraycopy(keyByte,0, salt, 0, keyByte.length / 2);
|
||||
System.arraycopy(keyByte,keyByte.length / 2, encryptKey, 0, keyByte.length / 2);
|
||||
try {
|
||||
//byte[] raw = key.getBytes(StandardCharsets.UTF_8);
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(encryptKey, "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
|
||||
IvParameterSpec ivParameter = new IvParameterSpec(salt);
|
||||
cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivParameter);
|
||||
try {
|
||||
//byte[] encrypted1 = Hex.decodeHex(content);// 先用base64解密
|
||||
byte[] encrypted1 = Base64.getDecoder().decode(content);
|
||||
byte[] original = cipher.doFinal(encrypted1);
|
||||
return new String(original);
|
||||
} catch (Exception e) {
|
||||
log.info(e.toString());
|
||||
return null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info(ex.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//sha256加密
|
||||
byte[] sha256Str = PasswordUtil.getSHA256Str("123456");
|
||||
//AES加密
|
||||
String encrypt = Aes128Util.AESEncode("9121184", sha256Str);
|
||||
|
||||
System.out.println(encrypt);
|
||||
|
||||
String s = Aes128Util.AESDecode(encrypt, sha256Str);
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public final class CodecUtil {
|
||||
|
||||
/**
|
||||
* 将url编码
|
||||
*/
|
||||
public static String encodeURL(String source) {
|
||||
try {
|
||||
return URLEncoder.encode(source, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将url解码
|
||||
*/
|
||||
public static String decodeURL(String source) {
|
||||
try {
|
||||
return URLDecoder.decode(source, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import static com.mhhy.service.impl.LoginServiceImpl.conversationFlag;
|
||||
|
||||
public class JsonUtil {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 将 POJO 转为 JSON
|
||||
*/
|
||||
public static <T> String toJson(T obj) {
|
||||
String json;
|
||||
try {
|
||||
json = OBJECT_MAPPER.writeValueAsString(obj);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 JSON 转为 POJO
|
||||
*/
|
||||
public static <T> T fromJson(String json, Class<T> type) {
|
||||
T pojo;
|
||||
try {
|
||||
pojo = OBJECT_MAPPER.readValue(json, type);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return pojo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密并返回具体类型
|
||||
* @param data
|
||||
* @param userId
|
||||
* @param obj
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T getResult(String data, int userId, Class<T> obj) {
|
||||
T pojo = null;
|
||||
try {
|
||||
//获取会话密钥
|
||||
String conversationId = RedisUtil.get(conversationFlag + userId);
|
||||
if (conversationId == null) {
|
||||
System.out.println("conversationId is null.");
|
||||
return null;
|
||||
}
|
||||
//对数据进行解密
|
||||
System.out.println("conversationId : " + conversationId);
|
||||
System.out.println("data : " + data);
|
||||
|
||||
byte[] bytes = PasswordUtil.getSHA256Str(conversationId);
|
||||
String result = Aes128Util.AESDecode(data, bytes);
|
||||
|
||||
System.out.println("result : " + result);
|
||||
|
||||
pojo = JsonUtil.fromJson(result, obj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return pojo;
|
||||
}
|
||||
|
||||
public static String genResult(JSONObject json, int userId) {
|
||||
try {
|
||||
//获取会话密钥
|
||||
String conversationId = RedisUtil.get(conversationFlag + userId);
|
||||
//对数据进行解密
|
||||
byte[] bytes = PasswordUtil.getSHA256Str(conversationId);
|
||||
String result = Aes128Util.AESEncode(json.toString(), bytes);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class MD5 {
|
||||
|
||||
//十六进制下数字到字符的映射数组
|
||||
private final static String[] hexDigits = {"0", "1", "2", "3", "4",
|
||||
"5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* md5加密算法
|
||||
* @param originString
|
||||
* @return
|
||||
*/
|
||||
public static String encodeByMD5(String originString){
|
||||
if (originString != null){
|
||||
try{
|
||||
//创建具有指定算法名称的信息摘要
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
//使用指定的字节数组对摘要进行最后更新,然后完成摘要计算
|
||||
byte[] results = md.digest(originString.getBytes());
|
||||
//将得到的字节数组变成字符串返回
|
||||
String resultString = byteArrayToHexString(results);
|
||||
return resultString.toUpperCase();
|
||||
} catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String encodeByMD5NoTUpperCase(String originString){
|
||||
StringBuffer sb = new StringBuffer(32);
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] array = md.digest(originString.getBytes("utf-8"));
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).toUpperCase().substring(1, 3));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* 转换字节数组为十六进制字符串
|
||||
* @param
|
||||
* @return 十六进制字符串
|
||||
*/
|
||||
private static String byteArrayToHexString(byte[] b){
|
||||
StringBuffer resultSb = new StringBuffer();
|
||||
for (int i = 0; i < b.length; i++){
|
||||
resultSb.append(byteToHexString(b[i]));
|
||||
}
|
||||
return resultSb.toString();
|
||||
}
|
||||
|
||||
/** 将一个字节转化成十六进制形式的字符串 */
|
||||
private static String byteToHexString(byte b){
|
||||
int n = b;
|
||||
if (n < 0)
|
||||
n = 256 + n;
|
||||
int d1 = n / 16;
|
||||
int d2 = n % 16;
|
||||
return hexDigits[d1] + hexDigits[d2];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
package com.mhhy.util;
|
||||
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
* @author zcw
|
||||
* @version 1.0
|
||||
* @date 2020/1/6 17:03
|
||||
* @description md5工具类
|
||||
*/
|
||||
public class Md5Util {
|
||||
|
||||
public static String md5(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
return DigestUtils.md5DigestAsHex(str.getBytes());
|
||||
}
|
||||
|
||||
public static String MD5(String data) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] array = md.digest(data.getBytes("UTF-8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte item : array) {
|
||||
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
|
||||
}
|
||||
return sb.toString().toUpperCase();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import sun.misc.BASE64Decoder;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.Key;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public class PasswordUtil {
|
||||
/**平台加密算法
|
||||
* //前端获取服务端随机数
|
||||
* //前端使用 用户密码+sha256加密 对随机数进行加密
|
||||
* //后端生成密文流程:用户登录密码+sha256+base64--入库
|
||||
* //后端解析前端密文:拿数据库数据进行base64反解密--对前端传递过来的密钥解密--结果是一个服务端生产的随机数。
|
||||
* //随机数去比对缓存里面的随机数
|
||||
* //随机数设置过期时间 5分钟
|
||||
*/
|
||||
|
||||
//sha256加密
|
||||
public static byte[] getSHA256Str(String str){
|
||||
MessageDigest messageDigest;
|
||||
String encdeStr = "";
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hash = messageDigest.digest(str.getBytes("UTF-8"));
|
||||
return hash;
|
||||
//encdeStr = Hex.encodeHexString(hash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//base64编码
|
||||
public static String encoderBase64(byte[] sha256){
|
||||
return java.util.Base64.getEncoder().encodeToString(sha256);
|
||||
}
|
||||
|
||||
//base64 解码
|
||||
public static byte[] decodeBase64(String encoderBase64){
|
||||
return java.util.Base64.getDecoder().decode(encoderBase64);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//sha256加密
|
||||
byte[] sha256Str = PasswordUtil.getSHA256Str("111111");
|
||||
//AES加密
|
||||
String encrypt = Aes128Util.AESEncode("10908325", sha256Str);
|
||||
|
||||
System.out.println(encrypt);
|
||||
String str = "bHCrPMT2MFqhbXdjh_fCRwNQkGruSOU2nk4ZHmRB02H4DLOxzIcpbVOJSZmMPpMMa5HLTPq7PGweInFL9p1YE5sSmlgpUWWl5Kfb_Cstay0Gb4U7HkcS5rNxpiFj45C1SsGxQhG7qEJ7qSxId3Ho_Qgs-T7XTfYM8b_9MM26Yz9-g5EXVoItwXWUlfGEf2dbruFH1jFn4_6wGYawb4SsehIPqmSoTx8oaVRABZcq9Xo=";
|
||||
String s = Aes128Util.AESDecode(str, sha256Str);
|
||||
String[] mhhy2022s = s.split("MHHY2022");
|
||||
System.out.println("token:" + mhhy2022s[0]);
|
||||
System.out.println("会话id:" + mhhy2022s[1]);
|
||||
|
||||
String data = "{\"password\": \"111111\"}";
|
||||
String result = Aes128Util.AESEncode(data, PasswordUtil.getSHA256Str(mhhy2022s[1]));
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomUtil {
|
||||
|
||||
//传入list数组后随机排列
|
||||
public static int[] getSequence(List<Integer> list) {
|
||||
int[] sequence = new int[list.size()];
|
||||
for(int i = 0; i < list.size(); i++){
|
||||
sequence[i] = list.get(i);
|
||||
}
|
||||
Random random = new Random();
|
||||
for(int i = 0; i < list.size(); i++){
|
||||
int p = random.nextInt(list.size());
|
||||
int tmp = sequence[i];
|
||||
sequence[i] = sequence[p];
|
||||
sequence[p] = tmp;
|
||||
}
|
||||
return sequence;
|
||||
}
|
||||
|
||||
//获取某个范围内的随机数
|
||||
public static int getRandomArea(int i){
|
||||
Random random = new Random();
|
||||
return random.nextInt(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机数
|
||||
* @param j 随机数的位数
|
||||
* @return
|
||||
*/
|
||||
public static String getRandomToNum(int j){
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
int str[] = {1,2,3,4,5,6,7,8,9,0};
|
||||
for (int i = 0; i < j; i ++){
|
||||
double num = Math.random();
|
||||
int a = (int) (num * 10);
|
||||
buffer.append(a);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
//获取随机数
|
||||
public static String getRandom(){
|
||||
Random random = new Random();
|
||||
int rand = 1000000 + random.nextInt(10000000);
|
||||
return "" + rand;
|
||||
}
|
||||
|
||||
//获取邀请码 6位数
|
||||
public static String getRandomToInviteCode(int number){
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String str[] = {"1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
|
||||
for (int i = 0; i < number; i ++){
|
||||
double num = Math.random();
|
||||
int a = (int) (num * str.length);
|
||||
buffer.append(str[a]);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 邀请码
|
||||
* @param j 需要邀请码的位数
|
||||
* @return
|
||||
*/
|
||||
public static String getRandomToInviteCodeToNum(int j){
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String str[] = {"1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
|
||||
for (int i = 0; i < j; i ++){
|
||||
double num = Math.random();
|
||||
int a = (int) (num * str.length);
|
||||
buffer.append(str[a]);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static String getRandomHeadUrl(){
|
||||
String str[] = {"https://www.cnqhcs.com/java/head/1.png", "https://www.cnqhcs.com/java/head/2.png"};
|
||||
double num = Math.random();
|
||||
Random random = new Random();
|
||||
int i = random.nextInt(str.length);
|
||||
return str[i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import com.mhhy.SpringContextHolder;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.ListOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* redis工具类
|
||||
*/
|
||||
public class RedisUtil {
|
||||
|
||||
private final static StringRedisTemplate stringRedisTemplate = SpringContextHolder.getBean("stringRedisTemplate");
|
||||
|
||||
/**
|
||||
* 匹配key
|
||||
*/
|
||||
public static Set<String> keys(String pattern) {
|
||||
return stringRedisTemplate.keys(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个key
|
||||
*/
|
||||
public static void del(String key) {
|
||||
stringRedisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除key
|
||||
*/
|
||||
public static void delByPattern(String pattern) {
|
||||
Set<String> keySet = keys(pattern);
|
||||
stringRedisTemplate.delete(keySet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置过期时间,单位为秒
|
||||
*/
|
||||
public static boolean expire(String key, long seconds) {
|
||||
return stringRedisTemplate.expire(key, seconds, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自动过期时间
|
||||
*/
|
||||
public static long ttl(String key) {
|
||||
return stringRedisTemplate.getExpire(key, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除过期时间
|
||||
*/
|
||||
public static boolean persist(String key) {
|
||||
return stringRedisTemplate.persist(key);
|
||||
}
|
||||
|
||||
/////// String 操作
|
||||
|
||||
/**
|
||||
* 给key赋值
|
||||
*/
|
||||
public static void set(String key, String value) {
|
||||
ValueOperations<String, String> op = stringRedisTemplate.opsForValue();
|
||||
op.set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给key赋值,并设置过期时间,单位为秒
|
||||
*/
|
||||
public static void setEx(String key, String value, long seconds) {
|
||||
set(key, value);
|
||||
expire(key, seconds);
|
||||
}
|
||||
|
||||
public static boolean setNewNx(String key,String value,long seconds ){
|
||||
ValueOperations<String, String> op = stringRedisTemplate.opsForValue();
|
||||
return op.setIfAbsent(key, value,Duration.ofSeconds(seconds));
|
||||
}
|
||||
public static boolean setNx(String key, String value) {
|
||||
ValueOperations<String, String> op = stringRedisTemplate.opsForValue();
|
||||
return op.setIfAbsent(key, value);
|
||||
}
|
||||
|
||||
public static void getLock(String key){
|
||||
getLock(key, 2L);
|
||||
}
|
||||
|
||||
public static void getLock(String key, long expireSecond) {
|
||||
if (expireSecond > 10) {
|
||||
expireSecond = 2;
|
||||
}
|
||||
String md5Key = "vexLock:" + key + ":" + Md5Util.md5(key);
|
||||
String value = "0";
|
||||
while (!setNx(md5Key, value)) {
|
||||
sleep(20);
|
||||
}
|
||||
expire(md5Key, expireSecond);
|
||||
}
|
||||
|
||||
public static void unLock(String key) {
|
||||
String md5Key = "vexLock:" + key + ":" + Md5Util.md5(key);
|
||||
del(md5Key);
|
||||
}
|
||||
|
||||
public static void sleep(int timeMills) {
|
||||
try {
|
||||
Thread.sleep(timeMills);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将key的值加num
|
||||
*/
|
||||
public static long incrBy(String key, long num) {
|
||||
ValueOperations<String, String> op = stringRedisTemplate.opsForValue();
|
||||
return op.increment(key, num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取key的值
|
||||
*/
|
||||
public static String get(String key) {
|
||||
ValueOperations<String, String> op = stringRedisTemplate.opsForValue();
|
||||
return op.get(key);
|
||||
}
|
||||
|
||||
/////// list操作
|
||||
|
||||
/**
|
||||
* 插入到表头
|
||||
*/
|
||||
public static void lPush(String key, String... values) {
|
||||
ListOperations<String, String> listOp = stringRedisTemplate.opsForList();
|
||||
listOp.leftPushAll(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除第一个
|
||||
*/
|
||||
public static String rPop(String key) {
|
||||
ListOperations<String, String> listOp = stringRedisTemplate.opsForList();
|
||||
return listOp.rightPop(key);
|
||||
}
|
||||
|
||||
public static int lLen(String key) {
|
||||
ListOperations<String, String> opsForList = stringRedisTemplate.opsForList();
|
||||
return opsForList.size(key).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取list所有
|
||||
*
|
||||
* @param key
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
public static List<String> lRange(String key, int start, int end) {
|
||||
ListOperations<String, String> opsForList = stringRedisTemplate.opsForList();
|
||||
return opsForList.range(key, start, end);
|
||||
}
|
||||
|
||||
/////// hash
|
||||
|
||||
/*
|
||||
* public static void hset(String key,String hashKey,String value){
|
||||
* HashOperations<String,String,String> opsForHash =
|
||||
* stringRedisTemplate.opsForHash(); opsForHash.put(key, hashKey, value); }
|
||||
*/
|
||||
/////// set
|
||||
/////// sorted set
|
||||
|
||||
/**
|
||||
* 存放list
|
||||
* @param key
|
||||
* @param list
|
||||
*/
|
||||
public static void setList(String key, List<String> list){
|
||||
ListOperations<String, String> opsForList = stringRedisTemplate.opsForList();
|
||||
opsForList.leftPushAll(key, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashGet
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 不能为null
|
||||
* @return 值
|
||||
*/
|
||||
public static String hGet(String key, String item) {
|
||||
HashOperations<String, String, String> mapOp = stringRedisTemplate.opsForHash();
|
||||
return mapOp.get(key, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取hashKey对应的所有键值
|
||||
* @param key 键
|
||||
* @return 对应的多个键值
|
||||
*/
|
||||
public static Map<String, String> hmGet(String key) {
|
||||
HashOperations<String, String, String> mapOp = stringRedisTemplate.opsForHash();
|
||||
return mapOp.entries(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet
|
||||
* @param key 键
|
||||
* @param map 对应多个键值
|
||||
* @return true 成功 false 失败
|
||||
*/
|
||||
public static boolean hmSet(String key, Map<String,String> map){
|
||||
try {
|
||||
HashOperations<String, String, String> mapOp = stringRedisTemplate.opsForHash();
|
||||
mapOp.putAll(key, map);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet 并设置时间
|
||||
* @param key 键
|
||||
* @param map 对应多个键值
|
||||
* @param time 时间(秒)
|
||||
* @return true成功 false失败
|
||||
*/
|
||||
public static boolean hmset(String key, Map<String, String> map, long time) {
|
||||
try {
|
||||
HashOperations<String, String, String> mapOp = stringRedisTemplate.opsForHash();
|
||||
mapOp.putAll(key, map);
|
||||
if (time > 0) {
|
||||
expire(key, time);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向一张hash表中放入数据,如果不存在将创建
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param value 值
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public static boolean hset(String key, String item, String value) {
|
||||
try {
|
||||
HashOperations<String, String, String> mapOp = stringRedisTemplate.opsForHash();
|
||||
mapOp.put(key, item, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向一张hash表中放入数据,如果不存在将创建
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param value 值
|
||||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public static boolean hset(String key,String item,Object value,long time) {
|
||||
try {
|
||||
HashOperations<String, Object, Object> mapOp = stringRedisTemplate.opsForHash();
|
||||
mapOp.put(key, item, value);
|
||||
if(time>0){
|
||||
expire(key, time);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除hash表中的值
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 可以使多个 不能为null
|
||||
*/
|
||||
public static void hdel(String key, Object... item){
|
||||
HashOperations<String, Object, Object> mapOp = stringRedisTemplate.opsForHash();
|
||||
|
||||
mapOp.delete(key,item);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断hash表中是否有该项的值
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 不能为null
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
public static boolean hHasKey(String key, String item){
|
||||
HashOperations<String, Object, Object> mapOp = stringRedisTemplate.opsForHash();
|
||||
|
||||
return mapOp.hasKey(key, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param by 要增加几(大于0)
|
||||
* @return
|
||||
*/
|
||||
public static double hincr(String key, String item,double by){
|
||||
HashOperations<String, Object, Object> mapOp = stringRedisTemplate.opsForHash();
|
||||
|
||||
return mapOp.increment(key, item, by);
|
||||
}
|
||||
|
||||
/**
|
||||
* hash递减
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param by 要减少记(小于0)
|
||||
* @return
|
||||
*/
|
||||
public static double hdecr(String key, String item,double by){
|
||||
HashOperations<String, Object, Object> mapOp = stringRedisTemplate.opsForHash();
|
||||
|
||||
return mapOp.increment(key, item,-by);
|
||||
}
|
||||
|
||||
/**
|
||||
* set中增加元素,支持一次增加多个元素,逗号分隔即可,结果返回添加的个数
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static Long addSet(String key, String... value) {
|
||||
Long size = null;
|
||||
try {
|
||||
size = stringRedisTemplate.opsForSet().add(key, value);
|
||||
} catch (Exception e) {
|
||||
//log.error("[RedisUtils.addSet] [error]", e);
|
||||
return size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
/**
|
||||
* set中移除指定元素
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static Long removeSet(String key, Object value) {
|
||||
Long size = null;
|
||||
try {
|
||||
size = stringRedisTemplate.opsForSet().remove(key, value);
|
||||
} catch (Exception e) {
|
||||
//log.error("[RedisUtils.removeSet] [error]", e);
|
||||
return size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取key下的所有元素
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> members(String key) {
|
||||
Set<String> result = null;
|
||||
try {
|
||||
result = stringRedisTemplate.opsForSet().members(key);
|
||||
} catch (Exception e) {
|
||||
//log.error("[RedisUtils.members] [error]", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mhhy.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public enum RegexEnum {
|
||||
|
||||
PHONE("^1\\d{10}$"),
|
||||
EMAIL("^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$"),
|
||||
// 密码长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种
|
||||
PASSWORD("^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$");
|
||||
|
||||
private String regx;
|
||||
|
||||
RegexEnum(String regx) {
|
||||
this.regx = regx;
|
||||
}
|
||||
|
||||
public boolean isMatcher(String val){
|
||||
Pattern p = Pattern.compile(regx);
|
||||
Matcher m = p.matcher(val);
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
public String getRegx() {
|
||||
return regx;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 117 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user