Compare commits
669 Commits
temp0516
...
release/3.
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c2b4ffc48 | |||
| b90df7468e | |||
| 370d9402f2 | |||
| 4d518d05b9 | |||
| 13514b277b | |||
| d6c5d0e95d | |||
| 301a62a563 | |||
| 22e5a97143 | |||
| 765d404845 | |||
| d5cf4e9d3f | |||
| 4b7fd649a3 | |||
| 6249d53b7b | |||
| b445f1f11e | |||
| 5c66ece467 | |||
| 3b6b0c7e2c | |||
| 9a81fb7ee4 | |||
| 31bb29f2fd | |||
| c7b46229b5 | |||
| 1482bb6ab2 | |||
| eae4087b3e | |||
| faf98607c4 | |||
| c19e9094d1 | |||
| db55c5597f | |||
| 0c79739867 | |||
| e484f22788 | |||
| 6a694cee18 | |||
| 1a077edf0c | |||
|
|
68926757dc | ||
|
|
eea57435e5 | ||
| 1f0e8f9cf2 | |||
|
|
63ee41e3b8 | ||
|
|
08072001a7 | ||
| 6b4d82a67d | |||
| 5612b5b1d4 | |||
| 1d46a3b6d4 | |||
| 0500557dca | |||
| 654a3829c6 | |||
| fccafba438 | |||
| 8cd4cfb36d | |||
|
|
7e55b1f85e | ||
|
|
a043db2de5 | ||
|
|
d3ee0e5f4f | ||
|
|
484a8d1d93 | ||
|
|
7839ac3322 | ||
|
|
e16f494cf4 | ||
|
|
6fc22784b8 | ||
| 52bafa95e3 | |||
| 377c86e390 | |||
| d809362ea7 | |||
| c08987a781 | |||
| e60c3d7aa3 | |||
| 614b8d0948 | |||
| 8834b906f4 | |||
| 828a022768 | |||
| 26c8d08d04 | |||
| 68a9b2281a | |||
| 63df493d33 | |||
| b7110c80b5 | |||
| c4dbd10a85 | |||
| 041a407978 | |||
| f73c997c38 | |||
| db2a955dea | |||
| a91643d2ec | |||
| 269cf7ea03 | |||
| e3aa964db8 | |||
| fa2fa66d4a | |||
| 6d2a189fef | |||
| 2033f61c7e | |||
| 4e2222966f | |||
| fbe9dc87e9 | |||
| d6f078ab60 | |||
| a940863799 | |||
| 11ffa66851 | |||
| fc3fa22bee | |||
| 37ff60fcfb | |||
| d2d5eebe12 | |||
| 9cfb5aa344 | |||
| 5e7f898840 | |||
|
|
6d3253aed3 | ||
|
|
52e5f246ce | ||
|
|
6222377bc5 | ||
|
|
2d10f57643 | ||
|
|
5f27a95498 | ||
|
|
7fdf832f44 | ||
| 43d2f83677 | |||
| e882a15aa0 | |||
| 1a3f16119b | |||
| 8e2e515af3 | |||
| f1a2495431 | |||
| c66b794daa | |||
| b9f7ea2722 | |||
| 455e17d4b1 | |||
| a1a6a78dac | |||
| 07f91aef74 | |||
|
|
079ab4d98f | ||
|
|
6e53bc3ca5 | ||
|
|
5e8eb716b1 | ||
|
|
34ee8fa11d | ||
|
|
b7dc95af26 | ||
|
|
297391d57e | ||
|
|
aff870fba7 | ||
| 7b1ac47228 | |||
| 7eb9abbdb5 | |||
| 521bd5071a | |||
| ab7e1705c4 | |||
|
|
a2390a6ab2 | ||
|
|
8dc5dcb1bd | ||
|
|
5d010d2f77 | ||
|
|
cec5544472 | ||
|
|
5f79c3276a | ||
| aadb717c9f | |||
| e2e9201fdd | |||
|
|
9053bdf10c | ||
|
|
b14297d1af | ||
|
|
e90979bbdc | ||
|
|
e02c278e7a | ||
|
|
e60d9483a3 | ||
|
|
ba49312fd5 | ||
| ba3c98771f | |||
| 4c738cc61d | |||
| d648a79ec4 | |||
| c325927418 | |||
| dba5625446 | |||
| 91189968e9 | |||
| 433d8a460e | |||
| ec9857fe73 | |||
| a9b01566e1 | |||
|
|
a384aba4df | ||
| e587ad3ca1 | |||
|
|
6a7c8b3d28 | ||
|
|
6f52c956ec | ||
|
|
9e5d2f47e2 | ||
|
|
627f264ef3 | ||
|
|
464de4ee5a | ||
|
|
cf76235123 | ||
| 8d9f51f50f | |||
| d840185ec7 | |||
| 9f4ab20b9d | |||
| 0877ff8f66 | |||
| 78046e8707 | |||
|
|
9fb8bc989d | ||
|
|
3c89670dae | ||
| 21b73d55f7 | |||
| 9199cdf7e2 | |||
|
|
8589216a77 | ||
|
|
87768c6b53 | ||
|
|
ca320f4334 | ||
|
|
7697ab59fa | ||
| e5e6f360dc | |||
| 68a9462714 | |||
| b185a94fcc | |||
| 708280ca14 | |||
| 0ab1e7eef7 | |||
| c7b1d46b18 | |||
| 9357a62f0c | |||
| c5b25e9a16 | |||
| a35d057146 | |||
| 7fc495eec9 | |||
| 46f37942d2 | |||
| e75196c904 | |||
| bdfa249c2e | |||
| d0e5f7da61 | |||
| d8320ba83d | |||
| 23460800d6 | |||
| 58c8b644bc | |||
| c4c04aecb6 | |||
| bb7c98c094 | |||
| dcdb0d06c4 | |||
| b6a66bed41 | |||
|
|
5f277ed815 | ||
|
|
845a553097 | ||
| 74f89c8b2d | |||
| cff8227228 | |||
| 51e2c9af02 | |||
| cd89a77189 | |||
| ab303cfeef | |||
|
|
07004a7415 | ||
|
|
d2069a3e7f | ||
|
|
501cee0057 | ||
| ac2454fd0e | |||
| 931a4cf807 | |||
| cb7099264e | |||
| e7aa951e89 | |||
| ef70598180 | |||
| 698fca8787 | |||
| 2f86090f21 | |||
| 2988a3b34e | |||
|
|
4fe5f65867 | ||
|
|
4bb1953d4a | ||
|
|
57a8260f03 | ||
| e4936a23bc | |||
| 9f37cb3f8d | |||
| b128b2436d | |||
| 66158e94dd | |||
| f6b489d950 | |||
| 30312caf82 | |||
| 1d0dd65f5e | |||
|
|
0b245f62af | ||
| 50d90af3a5 | |||
|
|
49b8585522 | ||
|
|
b49f098a5e | ||
| e9a15b950e | |||
| ee676614f8 | |||
| 710abf2323 | |||
| 1a9f06d259 | |||
|
|
eaaa99a946 | ||
|
|
c8e4d624b7 | ||
| f08e36d100 | |||
| de73536d1c | |||
| 6a861305d6 | |||
|
|
367fa130c0 | ||
|
|
d04987a3e2 | ||
| b0fa185d36 | |||
| 094718e67f | |||
| e4a8bf80e9 | |||
|
|
c04b102a81 | ||
|
|
da9b3a04b4 | ||
|
|
234a030801 | ||
|
|
5ea8e851d7 | ||
|
|
afeeef4af7 | ||
| ee1e2f8556 | |||
| 1157b41730 | |||
| ca4d75c63f | |||
| f45bd7acc4 | |||
| 7bdd62d4a9 | |||
| b01ee9129b | |||
|
|
214c93923c | ||
|
|
bfa1d67b5c | ||
| a0a1a1a06a | |||
| 468ad385d7 | |||
| fa94667c0f | |||
| c997fbf1cb | |||
| 7283ace072 | |||
|
|
69743d4ef0 | ||
|
|
e033671ffb | ||
|
|
15cde37af7 | ||
|
|
7fb74bc7d8 | ||
| 43968995ea | |||
| 0574180e4b | |||
| 5b653272ee | |||
| d28a6051f1 | |||
| f9063ad26e | |||
| 2f4d060ca3 | |||
| fcd0cf4836 | |||
| 26f50c2acb | |||
| c3eb1fc78c | |||
| b15cc542e1 | |||
|
|
ec094d7471 | ||
|
|
3dc432131c | ||
|
|
1a19604163 | ||
| fdebb2b215 | |||
| 7d8f047087 | |||
| bf8af41f3f | |||
|
|
cdf29d2b0d | ||
|
|
7194049127 | ||
|
|
e34cec812f | ||
|
|
11a5b53d2a | ||
| efe22de0a0 | |||
|
|
82f7571612 | ||
|
|
2ac54a50ec | ||
| 5dd1e10b61 | |||
| e9e8e87719 | |||
| 3c0fa205d1 | |||
| 47ca7bde41 | |||
|
|
9e28d579d1 | ||
|
|
1c96522447 | ||
|
|
1a568621ca | ||
| eecefee674 | |||
| ea0332851d | |||
| a25a7dc023 | |||
|
|
b4fe1ca199 | ||
|
|
b315ae5644 | ||
|
|
f7113601f3 | ||
|
|
8d6e3e9644 | ||
|
|
23b864d378 | ||
|
|
be1119be6f | ||
|
|
b836e7fd67 | ||
| a237b4041d | |||
| ea4cd29723 | |||
| 13397fa1f7 | |||
| 2fab472150 | |||
| 8c71b4845a | |||
| b70f909a32 | |||
| 1b15aed6a2 | |||
| 5019fbd3fc | |||
| 2ea19dcf03 | |||
| 4d756d5624 | |||
| f6f759110f | |||
| 8d27b5b51e | |||
|
|
9f064609e7 | ||
|
|
fd10d4dbc4 | ||
|
|
fadb5faf0d | ||
| e5e514b522 | |||
| 74e6d5a1da | |||
| 3cf0570912 | |||
|
|
8da51a0a82 | ||
|
|
37ff7fbb91 | ||
|
|
8c20b51e13 | ||
| 391a28d659 | |||
| 4535fb7dfb | |||
| 546d1b4c44 | |||
| 5fe605c130 | |||
| 4408c0ecc6 | |||
| 49f08d1191 | |||
| 903bafb245 | |||
| 59b02b3f28 | |||
| 4a23e33080 | |||
| 1e1b06fc48 | |||
| 7c56d2bf4e | |||
| 4add0a806c | |||
| c9bb7fe502 | |||
| a8a7a129c9 | |||
| c3c5532cb5 | |||
| 78bfc16287 | |||
|
|
6c6162df74 | ||
|
|
a837aff0fb | ||
|
|
f673afc7fc | ||
|
|
0ea96c728c | ||
|
|
77e71e3296 | ||
|
|
ce870b9acf | ||
|
|
7f889b54e0 | ||
|
|
ebd596d0d2 | ||
| 04ce95caa4 | |||
| 29bf172187 | |||
|
|
41619febb9 | ||
|
|
0f4b769d49 | ||
| 66cd8217b9 | |||
| e684c4e547 | |||
| c439f41d69 | |||
| 823e96b014 | |||
| 0cca24ee30 | |||
| 66cccd0867 | |||
| 463ddf3cb2 | |||
|
|
f0e0987f31 | ||
|
|
16bea58ab5 | ||
|
|
f2bbbaaeb6 | ||
|
|
5098f6f4a1 | ||
|
|
bc1815ae1b | ||
| 6256c90958 | |||
| f0bfe249e0 | |||
| 7bbfd7c506 | |||
| 3c7cbe28a1 | |||
| c834aacf3a | |||
| 90b0ef41e3 | |||
|
|
2aeeec4468 | ||
| a7c5723e10 | |||
|
|
ba595b9d2c | ||
|
|
d9118aaf93 | ||
| 1bdc71998b | |||
| a597f7a67a | |||
| 195964ef5a | |||
|
|
c27ca77717 | ||
|
|
7d0d460e5c | ||
| 5ac9df3056 | |||
| b8d64f1f28 | |||
| c8dd9664be | |||
| 8899a3a6bb | |||
|
|
67f56f9b84 | ||
|
|
fd12b9e571 | ||
| fb329c94aa | |||
| 16d06582ee | |||
|
|
6f98f111dd | ||
|
|
51a1c1d8e1 | ||
|
|
8445c23984 | ||
| 961f8f874e | |||
| 283b6244b1 | |||
| f19a15dbe8 | |||
| 791d44df02 | |||
|
|
28e67db78d | ||
|
|
63a120c652 | ||
|
|
f60cabbbc0 | ||
| 06db759749 | |||
|
|
373608d989 | ||
|
|
45e3dde03f | ||
|
|
3625180a6e | ||
| aae1442a6f | |||
| 08dcd03468 | |||
|
|
deda511e32 | ||
|
|
9bcf615b4b | ||
|
|
70912c4c43 | ||
|
|
fa013c1974 | ||
| 11fbeb1ed0 | |||
| f432b8cce6 | |||
|
|
05ddd33bcd | ||
|
|
9f5c901502 | ||
| 33d5d3a2ea | |||
| 2668dd3c47 | |||
| 2bc5fef175 | |||
| ea92e1f20d | |||
| 9f1cf1d90e | |||
| b43f9baead | |||
|
|
41ffe335fc | ||
|
|
56d0dcd25f | ||
|
|
4304acbe6f | ||
| 2f1b22d423 | |||
| 3eb8626831 | |||
| 5a86f2e649 | |||
| 93e9c61943 | |||
|
|
c5e9941adb | ||
| 56679808e9 | |||
|
|
40f5705e7a | ||
|
|
32975d9900 | ||
|
|
72db49e7f5 | ||
|
|
472f5e65b4 | ||
| e2f8fb082c | |||
| a47e53b19e | |||
| c01acec9e6 | |||
| 969d7586fc | |||
| 31a40ff7ca | |||
| afb9c99228 | |||
| 8ee6a529a0 | |||
| cebc05d132 | |||
| d23ac82b1b | |||
| e86b576050 | |||
| 8a774aa328 | |||
| c5da68dc47 | |||
| 28df672a7d | |||
| 203c88dd70 | |||
| fa86a2af45 | |||
| ac28ba233c | |||
|
|
47dc2bfc6e | ||
| 085dac0630 | |||
| 7b27b1362d | |||
| 704e3c25bf | |||
| 7e5b10aab3 | |||
| 3ccbd8f905 | |||
| 89a234e77d | |||
| 388dd54bfa | |||
| 035c4412f1 | |||
| d4eb7c846b | |||
| fef50d7a37 | |||
| e5a95972a5 | |||
|
|
36a796b38b | ||
| 94927ae0a4 | |||
| 4d7153661c | |||
| 76062136d6 | |||
| ea4ba74989 | |||
|
|
5a09d7a195 | ||
|
|
e0332b9ddf | ||
|
|
685ba09f7d | ||
|
|
7aa1fc0342 | ||
|
|
653264151a | ||
|
|
fada00c738 | ||
| a10d30337a | |||
| 85ffed114b | |||
| 1093ac68b6 | |||
| 71e6abd816 | |||
| 00c948116e | |||
| b6efd598bd | |||
| bfe7ad4aa6 | |||
| 018ccef46a | |||
| feb836f849 | |||
| 0106f21b86 | |||
| 1b5f64785d | |||
| 77a4aee88e | |||
|
|
ce1e2f3eab | ||
|
|
75fbd2844b | ||
|
|
832f331603 | ||
| 9a2d58d922 | |||
|
|
34c4cd47ef | ||
| c46f65600f | |||
| 56ebcfbce2 | |||
| aa1eb7411e | |||
| 4626ea3c55 | |||
| 5858f7dcf1 | |||
| 440dfdcceb | |||
| 36e41ecd89 | |||
| e1b08a9979 | |||
| b9041d9c09 | |||
| 037a0d12ff | |||
| 956b72729f | |||
| 9b185e6919 | |||
|
|
f77de3a1f4 | ||
| f03d32030d | |||
|
|
6a098ffa13 | ||
|
|
12c10167f1 | ||
|
|
679b213b6f | ||
|
|
6fa6c38398 | ||
| 925da9fa03 | |||
| 8f0d45adf9 | |||
| 505288fdb7 | |||
| 44e045ece3 | |||
| 429fdad2b7 | |||
| 46fbbd747e | |||
| 803bdfd291 | |||
|
|
6cbc4882fa | ||
|
|
54f8d4b5e0 | ||
|
|
314ad7a4f8 | ||
|
|
a56510c35a | ||
|
|
c2e2140ce6 | ||
| 83915d332f | |||
| 751aeb785d | |||
| 7cadab9345 | |||
|
|
8a7b64dd65 | ||
|
|
4c598200e5 | ||
|
|
d052918725 | ||
|
|
8fd6a3462e | ||
|
|
11eb6595dd | ||
|
|
0adfcb745d | ||
|
|
779e1e8be3 | ||
|
|
5297880c3b | ||
|
|
6028ef8cdd | ||
|
|
c7de1779bd | ||
|
|
95bfb00a9d | ||
|
|
5fc50f2d96 | ||
|
|
22d7395e11 | ||
|
|
3d4ea89516 | ||
|
|
2ed63cafd0 | ||
|
|
701652c6b2 | ||
|
|
df66b51e5c | ||
|
|
0c6187a759 | ||
|
|
2d6867b729 | ||
|
|
0b8d0a1843 | ||
| 64c7b8c1fd | |||
|
|
42f1d47f82 | ||
|
|
9ca0cd7c43 | ||
|
|
4c187d1fbd | ||
|
|
733de89883 | ||
|
|
0e1a5a70df | ||
| 5ecebd5117 | |||
| c6626b230a | |||
|
|
1cab7332f9 | ||
|
|
c1d88943a9 | ||
| bc85e561d2 | |||
|
|
be8968605b | ||
| 569c2e719f | |||
|
|
5fa7e36dc2 | ||
|
|
4a533b3cf0 | ||
| d2129459fe | |||
|
|
9784d07680 | ||
|
|
a71fa4df51 | ||
|
|
ce384dbba9 | ||
|
|
dd8f5696a2 | ||
|
|
4211bce256 | ||
|
|
bc240cd2ee | ||
|
|
f869f8eb10 | ||
|
|
9b438c78a3 | ||
| a5b435b80f | |||
| a64d4e30de | |||
| 0759452381 | |||
|
|
58a78a5366 | ||
|
|
9bd695a24d | ||
| e614e3a07a | |||
|
|
8c65592394 | ||
|
|
e093d694fd | ||
|
|
a5bfc4e41d | ||
| be001477ce | |||
| 3e150b2067 | |||
| 8ea06c05e9 | |||
|
|
9b589eece6 | ||
|
|
ba4388b87d | ||
|
|
5b3a668ce7 | ||
| aacbe92cdc | |||
| 57ab6c64ef | |||
| ffaef2ff6c | |||
| 5113cb0606 | |||
| 30d5466805 | |||
| 8457a61ded | |||
| e7f9b77fe5 | |||
|
|
6c0f65b801 | ||
|
|
ad1fa0e4c2 | ||
| 227c742f0d | |||
| c317942447 | |||
|
|
a6f02bf22f | ||
| 4f12aa92b6 | |||
| e6a2ce2b69 | |||
|
|
1f0439c7f9 | ||
|
|
676ef74bdc | ||
|
|
b2bc47da99 | ||
|
|
02787db0a1 | ||
| 19524520f4 | |||
| 2a2c4b1d39 | |||
| 257c99698e | |||
| 8ff8a7480f | |||
| 5e1ff16052 | |||
| dbd89798d5 | |||
| b5b6f737aa | |||
| 1d60a6a129 | |||
| 0017568cc7 | |||
|
|
375f717721 | ||
|
|
18914bea7e | ||
| fc48d8931f | |||
| 619d33b412 | |||
| 1a48527c70 | |||
|
|
ee68a5d782 | ||
|
|
3a29d25060 | ||
| 77f514a03b | |||
| 954f6207ec | |||
| 891f6fb15f | |||
| 49b086ad10 | |||
| 86e7119cfb | |||
|
|
775ae3266c | ||
| 1aea8e93f2 | |||
| 804dc9b1b4 | |||
| bd543e56d5 | |||
|
|
3dc7866fba | ||
|
|
ffd371e5b4 | ||
|
|
40aad9d1a3 | ||
| 709393a9a6 | |||
| fb8de15eca | |||
| f4e9a3474a | |||
|
|
890389843f | ||
| db04267591 | |||
| 5ff2bf11d7 | |||
| 76618de386 | |||
| eda92b3f0b | |||
|
|
b1b4b4147c | ||
|
|
4ba5f63a62 | ||
|
|
8b274b2822 | ||
| 54cbaf4b80 | |||
| c688af01f2 | |||
|
|
37de7d9276 | ||
|
|
02b3a407a9 | ||
| 5ebf0669f5 | |||
|
|
031d71bf99 | ||
|
|
205f0d54c5 | ||
|
|
50e46fed02 | ||
|
|
1303b1805a | ||
|
|
2845c2c8b9 | ||
|
|
cd817dbf57 | ||
| f9ce559915 | |||
| e40401f61f | |||
|
|
6e64eb741a | ||
|
|
c4a37f5d73 | ||
|
|
8f5a86db0b | ||
|
|
14c99f6c6b | ||
|
|
bf072e35f5 | ||
|
|
b8048704ba | ||
|
|
b6704c3caf | ||
|
|
6b07c84c80 | ||
|
|
980e1547cd | ||
|
|
ae2191f369 | ||
|
|
4b1a58c036 | ||
|
|
4dbd5a1fad | ||
|
|
b063cad764 | ||
|
|
f1eb48ae74 | ||
|
|
7233540ab4 | ||
|
|
e634481113 | ||
|
|
b3591f879d | ||
|
|
12c447d6b0 | ||
|
|
c73876e8b0 | ||
|
|
a726ceca59 | ||
|
|
51db8b4ec2 | ||
|
|
9f4dbda152 | ||
|
|
8e1766eed0 | ||
|
|
f1d67f2f7d | ||
|
|
ebb6577e98 | ||
| 5318e5d32a | |||
| 2aabb2347b | |||
| 3790b8ee72 | |||
| f4766d4ab4 | |||
| d1fab003d2 | |||
| 718198bcfe | |||
|
|
7b83f42ed8 | ||
| f23f4133d0 | |||
|
|
fb29310ba1 | ||
|
|
b86f168fe8 | ||
|
|
a54f7e7c30 | ||
|
|
de865b918f | ||
|
|
d2e917e3ce | ||
|
|
e70580c388 | ||
|
|
7454e16076 | ||
|
|
c3ae729466 | ||
|
|
faeb59bae5 | ||
|
|
5a69a770ac | ||
|
|
d1772be737 | ||
|
|
95aee1daae | ||
|
|
9bae02406c | ||
|
|
fda2a3120b |
9
files/COD-public-key.txt
Normal file
9
files/COD-public-key.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAymkBAWixxUi9IAeMWgsq
|
||||
K92AzFbe0qzzYPdkoh15ymL2A5MkYH7asnhFwclgdiFmd9a0TbZP+t/SzWW8UUzN
|
||||
1pXoEp48R+eguGTt5xkJwb10+H6quVXF/Ezzid5yzVW3dcYRp8qUlFr0XBpvkK9l
|
||||
FpPzh2+mwVEAsgBMXq/K50ZiX2dlkPZ7ffkVPWaK2ESIo3YgfM6dmiiza0hPWJ35
|
||||
UgTH5rwJ7vN3IdOJTlkQOvrIrj2ocPcrudeEwqybIbCGhgRBwQSBsXQOO4U//rE4
|
||||
VU+0LF/3uQgXkvVY1+a1JLiTncZYKGEQ/NtxM+dGtYWV2gPhQRyJ7Z77OX0XCbcn
|
||||
zwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -1,28 +0,0 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1XpZ0+EIoJvQk
|
||||
GHAdpcpr35S+UnxNdOE+1sZsIDWuyzXG0d6vOudITmYFTqVzJRaAArhwp+NQ/R9y
|
||||
onsuUsEc0x2qTntySYMedHfI2TSl6qTsqpHykSLr6u0E4TuYUiGs/nf3t0A/rEvm
|
||||
KK6OP4vNgUlANhOKDwiCAdmJkiOBEHJwLsN1xlcnBkUR0Wr+uauVo+A0opkM7HrB
|
||||
aXXTcy+gpold+uCgCbRzFCiDr0uKsLJgb3Ce1aXTwa8k2dDg6mzhE0U65yhsNzjC
|
||||
Cqg+g8tfEVha9Nrsmd6hG2iFHnk4rCqRXhjuI1V10GiZUppMWJtGD2tj7ZK0XXKh
|
||||
5sAclu9RAgMBAAECggEBAKSQy8IclKKsHbA2wFwWV6Ijv2olnAYH/G0xId9wJmWQ
|
||||
mx3oxb6Hmt3fzPAZ2UOuLkk+rq4Bl9+fnQ494bk5e2G1KWCjT512mFNk6F9EvmGh
|
||||
k73uUvkeueoIQsG/wHxIYaf/SUlqbBCaPE/9L82AWVDBc36g0n/dfiHAnesWv8JV
|
||||
agiTF/SIWDPtzRaVh8VObFOusHdqnRuLqV7n0FSVJePSNBFSSOz5XTttOtM4whg8
|
||||
kw3jlCHbVMVKtPYcebxGf0vkDapyGJiZ6wc1rD4MXJTciG+WQNfNE+Af2UB606VC
|
||||
Nlq/CRkXr2Ix9ASSMeE4TcH+0EoxeITpP2NV+3hAzgECgYEA7mWSd6HgPXMdwO33
|
||||
efmx0qky+I/4bhicG9Go6021fRY+jUhRcj6VtDWBzuZwblgTSiDH4t2TbfB+hvQD
|
||||
GVTJNc21+hXEVNu0ajqLuMiCgqaZCeNeJYYYowbLSbYd4t/nQh1vCZ/44aRWqG8G
|
||||
eWEGruMaqSlGyFG7kyaoQaY1X6ECgYEAwsMGiupkNZ/JU3PZd2X2X+37b8BXcIt7
|
||||
itL413GDiLwCNII5pArD7GHYFQzN4GaUCt/VjrRXbTY1xYCk2RA0FyBMsxAGa+eH
|
||||
9iTSLQvDJpxV/44UY3L9ZFcz4t0WjRcsdqPt30yUBNWiAIGcjtae2tMvtfxKICLQ
|
||||
sYXAS+ciMbECgYEA4tnerV5pfq/7QSpw0y4Ky5ZcPXDqiwF6E3LH1dlleTlgnpqR
|
||||
fjAVzp0X/+UCWc4P1PsqmjQU5YnzLMIn7MPkkAFHSEnMQJ+sp2U8rcKHhoG3oVQt
|
||||
s3FOIlwFuAfHmqtLaXuOvM7wSu9R0weLVpdAf8z2AsCXbWlxH86qT4Y0xeECgYBM
|
||||
NJkbw8i//qx8vciqYjf7oxeNy1mrTLhjQldhnSXVW5MVTpsVJ60vkb1Fx0PK+PgW
|
||||
JSzfcIsAzYROqh5WXHO1VMsOCUgp8mcNlayzOXX7ZpJzsvkhTH3/Q+umadGIFTgt
|
||||
l8jcZY9JMPn5br1+WlW/04BImdW7K0QzId1zFZYYkQKBgQDqswTLEpbBDOE/3uk4
|
||||
laZ9kTLJMP/hVmDJ0/jbETMdCkzIORnr3xFxmZIHG17E2In9PVumD0ESCh7qbCDE
|
||||
isbfLSgfJR6ItdOM6W2R0GAsXQ3e0byBpR7qm0j9J3zYRhQwfVbZtkX0uywB9a/4
|
||||
q2bz4491ESrbryx16FZKUJeX8g==
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -1,9 +0,0 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtV6WdPhCKCb0JBhwHaXK
|
||||
a9+UvlJ8TXThPtbGbCA1rss1xtHerzrnSE5mBU6lcyUWgAK4cKfjUP0fcqJ7LlLB
|
||||
HNMdqk57ckmDHnR3yNk0peqk7KqR8pEi6+rtBOE7mFIhrP5397dAP6xL5iiujj+L
|
||||
zYFJQDYTig8IggHZiZIjgRBycC7DdcZXJwZFEdFq/rmrlaPgNKKZDOx6wWl103Mv
|
||||
oKaJXfrgoAm0cxQog69LirCyYG9wntWl08GvJNnQ4Ops4RNFOucobDc4wgqoPoPL
|
||||
XxFYWvTa7JneoRtohR55OKwqkV4Y7iNVddBomVKaTFibRg9rY+2StF1yoebAHJbv
|
||||
UQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDD+NUduhLJcb2Z
|
||||
ryLwtIHdmjfh6Wn73E9umHmdPf6yF7IbDoTDBmIAfaPU/oiLgrka3fKGCkn/yHvW
|
||||
QcL+Ry96/Uu+iIN9SbG5vPVvLtLfx+5++IE8p3RxcSDQggqFuJ+osebXeVIrOcTZ
|
||||
s7nXCqGenTcagv2eJESiq712fcBvY1wVgilT6ERVQy+zdvwAOiS6wXF/51AueP+E
|
||||
rNDHuPLkGH6JhLtO4LffeYgM/Th7eCl/WWLkiVMSoeJt7vWFe4bYV/IYW1qI2aQX
|
||||
H1DYmvwgDfDv8jRORD9D191YBqq1l3Tw7VSjFrpydFvSK46dbXKBj3oA5ZiJ+Ttj
|
||||
ZCtBRiOdAgMBAAECggEAUKl4Fs9C8lV1o+85Y3f4yBy1CbCIZhltPGlYDUe6MNWe
|
||||
ApL8REW5Sthr+bx2uW2qAQv/yfosMTL0/eB9gSoNugLODXOlI4mUtI25O/U66M8j
|
||||
NHHWx/9o51SYHBqaeCXg2Y+4I1KVZqNVigH26TNACMhPKQNnnpLxCT/FMSNbdLzo
|
||||
wfFMyjN7R3Hc8ZB1C2zx+fLJm1DNZeOJOHAkW1LprlotRv6eq3lOwZaDDUTB5xhT
|
||||
0Erev3djC/R08Fne1y09ukar8z0tX3Fm9SzHJDFVoh1HOYPWayCiAxOhip+JnFct
|
||||
rtK5jjuB8DAP4Q1k12yOWUFwb6NOG9Hf/G6XExRPBQKBgQD1P2SnKD1IlNSrvVJn
|
||||
2HzKnBVllVo50fbv7SpnP8H1B5vt2Qo/mgOGtzbeXyK4mcLFaWg9++BrsjTXwZFi
|
||||
wmKeJgNI822DPhF5qQhK7Cc+WMwesufGrTnmRUOEFYehz9ffZBvMa1s/ObIEyLcr
|
||||
tYitT74+nFdRPtr+8PN06QMEcwKBgQDMkGFWhSO7p7VMuV0H0uC1fj3GGtVvM+Ps
|
||||
a9ASs0HBhQaOpberkKY9vgry6HoJ8CGvbrxlmc3JoYPRwKN3oQRYLvGSF96HAg9i
|
||||
643FmVAWiVzHpjYX9fMJyCzXiOw6Qet8Zp3Ewaw9BBG0200Fj6/zGc8XEqNjIv5Q
|
||||
DQ9MosRDrwKBgQCU5i5IRugeXy5YLxQPNKNfqDBdgrZLEK2qsgXithUencYQPIw6
|
||||
XVnyut43WO+NwN0+WmcN6xUwjfwDWuTYX0jc2Bt6eUFuQ4r8oKIGSybwdZ1IrjqG
|
||||
p7nVkwwQ77lvhu98FB3EmRHHa1IoEW0Uvp0DDL1m6ikhjNYNn2FRA//u/QKBgGbY
|
||||
a+eo1ldBMPha9Te6wLjeuEYCNa5L41p4tcrBDt0xeSN8k4QRHFNMWYrYcIrQjM77
|
||||
mIJoOjsWFgT9mfHKJToEl/VAROORmJS+Iq/mrYo3E0tY+DdBsygG2Oyf7Uw42iDY
|
||||
IpfKW0Lt6c0IuIeEPwy0vBY4i6aK8Frkxf1ck9oHAoGBAKFQg/c36J6tjnttpmes
|
||||
R/zijp1ROE+z+dMmm3icDhCDvvR6MnHa2Y9ittNWdEUosZk9FsFn62YNtJJV2SIN
|
||||
DDn0ASLtBkeCd8yad5uzUb7Umci9V7TP5c0NE3DK95FmciLGOuRbFyq1Z8edHnaS
|
||||
zgLnf4yb25eCMLEG0Z2ugN3C
|
||||
-----END PRIVATE KEY-----
|
||||
9
files/Code-Create Limited.merchant.aqs.public.key.pem
Normal file
9
files/Code-Create Limited.merchant.aqs.public.key.pem
Normal file
@@ -0,0 +1,9 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw/jVHboSyXG9ma8i8LSB
|
||||
3Zo34elp+9xPbph5nT3+sheyGw6EwwZiAH2j1P6Ii4K5Gt3yhgpJ/8h71kHC/kcv
|
||||
ev1LvoiDfUmxubz1by7S38fufviBPKd0cXEg0IIKhbifqLHm13lSKznE2bO51wqh
|
||||
np03GoL9niREoqu9dn3Ab2NcFYIpU+hEVUMvs3b8ADokusFxf+dQLnj/hKzQx7jy
|
||||
5Bh+iYS7TuC333mIDP04e3gpf1li5IlTEqHibe71hXuG2FfyGFtaiNmkFx9Q2Jr8
|
||||
IA3w7/I0TkQ/Q9fdWAaqtZd08O1Uoxa6cnRb0iuOnW1ygY96AOWYifk7Y2QrQUYj
|
||||
nQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
91
pom.xml
91
pom.xml
@@ -28,7 +28,19 @@
|
||||
<jaxb-core>4.0.0</jaxb-core>
|
||||
<activation>1.1.1</activation>
|
||||
<easy-captcha>1.6.2</easy-captcha>
|
||||
<aws.java.sdk.version>2.20.43</aws.java.sdk.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>${aws.java.sdk.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -139,9 +151,15 @@
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<!-- /**发送邮件**/-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.tencentcloudapi</groupId>-->
|
||||
<!-- <artifactId>tencentcloud-sdk-java-ses</artifactId>-->
|
||||
<!-- <version>3.1.572</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-ses</artifactId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<version>3.1.572</version>
|
||||
</dependency>
|
||||
|
||||
@@ -202,6 +220,13 @@
|
||||
<version>20230618</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
@@ -226,6 +251,70 @@
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.stripe</groupId>
|
||||
<artifactId>stripe-java</artifactId>
|
||||
<version>26.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- aws s3 -->
|
||||
<!-- S3 dependency -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3-transfer-manager</artifactId>
|
||||
<version>2.17.103-PREVIEW</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>kms</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3control</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.13.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.auth</groupId>
|
||||
<artifactId>google-auth-library-oauth2-http</artifactId>
|
||||
<version>1.8.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.32.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client</artifactId>
|
||||
<version>1.32.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client-jackson2</artifactId>
|
||||
<version>1.41.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
import com.ai.da.model.vo.GenerateResultVO;
|
||||
import com.ai.da.service.GenerateService;
|
||||
import com.ai.da.service.UserLikeGroupService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.rabbitmq.client.Channel;
|
||||
@@ -14,8 +15,10 @@ import org.apache.tomcat.jni.Time;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
@@ -30,6 +33,12 @@ public class GenerateConsumer {
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
|
||||
@Resource
|
||||
private UserLikeGroupService userLikeGroupService;
|
||||
|
||||
@Autowired
|
||||
private RabbitMQProperties rabbitMQProperties;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@@ -44,6 +53,10 @@ public class GenerateConsumer {
|
||||
|
||||
@Value("${redis.key.generateResult}")
|
||||
private String generateResultKey;
|
||||
@Value("${redis.key.toProductImageResultKey}")
|
||||
private String toProductImageResultKey;
|
||||
@Value("${redis.key.relightResultKey}")
|
||||
private String relightResultKey;
|
||||
|
||||
public void generate(Message msg, Channel channel, String consumerName) {
|
||||
log.info("============start listening==========");
|
||||
@@ -63,23 +76,14 @@ public class GenerateConsumer {
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费");
|
||||
}
|
||||
// 2.2 将该消息从取消列表中删除
|
||||
// redisUtil.removeFromSet(cancelSetKey, uniqueId);
|
||||
} else {
|
||||
// GenerateCollectionVO generateCollectionVO = generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
/*if (!Objects.isNull(generateCollectionVO)) {
|
||||
HashMap<String, String> generateResult = new HashMap<>();
|
||||
generateResult.put(uniqueId, JSONObject.toJSONString(generateCollectionVO));
|
||||
// 将结果存在redis中 ,为空时不要存
|
||||
redisUtil.addToMap(resultMapKey, generateResult);
|
||||
}*/
|
||||
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
log.error(e.getMsg());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
@@ -94,7 +98,7 @@ public class GenerateConsumer {
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateThroughImageTextDTO) +
|
||||
" Exception message : " + e.getMsg();
|
||||
" Exception message : " + e.getMessage();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
||||
// 存redis
|
||||
@@ -154,63 +158,175 @@ public class GenerateConsumer {
|
||||
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
public void processToProductImageResult(Message msg, Channel channel) {
|
||||
log.info("============processToProductImageResult listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
Map<String, String> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
||||
log.info("toProductImage response : {}", generateResult);
|
||||
|
||||
try {
|
||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
||||
if (generateResult.get("status").equals("SUCCESS")) {
|
||||
String url = generateResult.get("image_url");
|
||||
String taskId = generateResult.get("tasks_id");
|
||||
String category = generateResult.get("category");
|
||||
generateService.processToProductImageResult(taskId, url, category);
|
||||
} else if (generateResult.get("status").equals("NO_FACE")) {
|
||||
String taskId = generateResult.get("tasks_id");
|
||||
userLikeGroupService.toProduct(taskId);
|
||||
} else {
|
||||
// 修改redis中的数据状态为exception
|
||||
String key = toProductImageResultKey + ":" + generateResult.get("tasks_id");
|
||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.get("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
// 将异常信息存到exception中
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("data"));
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
try {
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.get("tasks_id"));
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||
" Exception message : " + e.getMessage();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
||||
log.info("============ProcessToProductImageResult End listening==========");
|
||||
}
|
||||
|
||||
private void processRelightResult(Message msg, Channel channel) {
|
||||
log.info("============processRelightResult listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
Map<String, String> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
||||
log.info("toProductImage response : {}", generateResult);
|
||||
|
||||
try {
|
||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
||||
if (generateResult.get("status").equals("SUCCESS")) {
|
||||
String url = generateResult.get("image_url");
|
||||
String taskId = generateResult.get("tasks_id");
|
||||
String category = generateResult.get("category");
|
||||
generateService.processRelightResult(taskId, url, category);
|
||||
} else if (generateResult.get("status").equals("NO_FACE")) {
|
||||
String taskId = generateResult.get("tasks_id");
|
||||
userLikeGroupService.relight(taskId);
|
||||
} else {
|
||||
// 修改redis中的数据状态为exception
|
||||
String key = relightResultKey + ":" + generateResult.get("tasks_id");
|
||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.get("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
// 将异常信息存到exception中
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("data"));
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
try {
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.get("tasks_id"));
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||
" Exception message : " + e.getMessage();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
||||
log.info("============ProcessRelightResult End listening==========");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer1(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 1");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer2(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 2");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer3(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 3");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer4(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 4");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer5(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 5");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer6(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 6");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer7(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 7");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer8(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 8");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||
@RabbitHandler
|
||||
public void generateConsumer9(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 9");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generateResult}")
|
||||
@RabbitHandler
|
||||
public void getGenerateResult(Message msg, Channel channel) {
|
||||
processGenerateResult(msg, channel);
|
||||
}
|
||||
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageResult}")
|
||||
@RabbitHandler
|
||||
public void getToProductImageResult(Message msg, Channel channel) {
|
||||
processToProductImageResult(msg, channel);
|
||||
}
|
||||
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.relightResult}")
|
||||
@RabbitHandler
|
||||
public void getRelightResult(Message msg, Channel channel) {
|
||||
processRelightResult(msg, channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,43 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MQConfig {
|
||||
|
||||
public static final String GENERATE_EXCHANGE_FANOUT = "generate-exchange";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
||||
// ==================================================================
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-local";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||
@Autowired
|
||||
private RabbitMQProperties rabbitMQProperties;
|
||||
|
||||
// public static final String SR_QUEUE = "SR-queue-local";
|
||||
public static final String SR_QUEUE = "SR-queue-dev";
|
||||
|
||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
|
||||
public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
||||
|
||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
||||
|
||||
public MQConfig() {
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// FanoutExchange fanoutRasaExchange() {
|
||||
// return new FanoutExchange(GENERATE_EXCHANGE_FANOUT);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 创建队列,使用工作模式,不用定义交换机
|
||||
*/
|
||||
@Bean
|
||||
public Queue generateQueue() {
|
||||
return new Queue(GENERATE_QUEUE);
|
||||
return new Queue(rabbitMQProperties.getQueues().getGenerate());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue SRQueue() {
|
||||
return new Queue(SR_QUEUE);
|
||||
return new Queue(rabbitMQProperties.getQueues().getSr());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue SRResultQueue() {
|
||||
return new Queue(SR_RESULT_QUEUE);
|
||||
return new Queue(rabbitMQProperties.getQueues().getSrResult());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将队列绑定到交换机上【队列订阅交换机】
|
||||
*/
|
||||
// @Bean
|
||||
// Binding bindingExchangeRasa() {
|
||||
// return BindingBuilder.bind(queueRasa()).to(fanoutRasaExchange());
|
||||
// }
|
||||
@Bean
|
||||
public Queue generateResultQueue() {
|
||||
return new Queue(rabbitMQProperties.getQueues().getGenerateResult());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue toProductImageResultQueue() {
|
||||
return new Queue(rabbitMQProperties.getQueues().getToProductImageResult());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue relightResultQueue() {
|
||||
return new Queue(rabbitMQProperties.getQueues().getRelightResult());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -10,19 +11,19 @@ import javax.annotation.Resource;
|
||||
@Component
|
||||
public class MQPublisher {
|
||||
|
||||
// private final String url = "http://localhost:15672/api/queues/%2f/generate-queue";
|
||||
@Autowired
|
||||
private RabbitMQProperties rabbitMQProperties;
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
private AmqpTemplate amqpTemplate;
|
||||
|
||||
public void sendGenerateMessage(String mm) {
|
||||
log.info("send message:" + mm);
|
||||
amqpTemplate.convertAndSend(MQConfig.GENERATE_QUEUE, mm);
|
||||
log.info("send message: " + mm);
|
||||
amqpTemplate.convertAndSend(rabbitMQProperties.getQueues().getGenerate(), mm);
|
||||
}
|
||||
|
||||
public void sendSRMessage(String mm) {
|
||||
log.info("send message:" + mm);
|
||||
amqpTemplate.convertAndSend(MQConfig.SR_QUEUE, mm);
|
||||
log.info("send message: " + mm);
|
||||
amqpTemplate.convertAndSend(rabbitMQProperties.getQueues().getSr(), mm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "rabbitmq")
|
||||
@Data
|
||||
public class RabbitMQProperties {
|
||||
|
||||
private Queues queues;
|
||||
private Exchange exchange;
|
||||
|
||||
@Data
|
||||
public static class Queues {
|
||||
private String generate;
|
||||
private String sr;
|
||||
private String srResult;
|
||||
private String generateResult;
|
||||
private String toProductImageResult;
|
||||
private String relightResult;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Exchange {
|
||||
private String generate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -27,6 +28,9 @@ import java.util.HashMap;
|
||||
@Component
|
||||
public class SRConsumer {
|
||||
|
||||
@Autowired
|
||||
private RabbitMQProperties rabbitMQProperties;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@@ -218,14 +222,13 @@ public class SRConsumer {
|
||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.SR_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.sr}")
|
||||
@RabbitHandler
|
||||
public void SRConsumer1(Message msg, Channel channel) {
|
||||
superResolution(msg, channel, "consumer 1");
|
||||
}
|
||||
|
||||
|
||||
@RabbitListener(queues = MQConfig.SR_RESULT_QUEUE)
|
||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.srResult}")
|
||||
@RabbitHandler
|
||||
public void SRResultConsumer1(Message msg, Channel channel) {
|
||||
getSRResult(msg, channel, "consumer 1");
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.ai.da.common.utils.ExcelReader;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.common.utils.SendEmailUtil;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
||||
import com.ai.da.model.enums.StyleEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@@ -17,15 +22,29 @@ import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MyTaskScheduler {
|
||||
|
||||
@PostConstruct
|
||||
public void test() {
|
||||
// clearMinio();
|
||||
// addSystemFileStyle();
|
||||
// sendTrialOrderExcelToManagements();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
|
||||
@@ -68,10 +87,11 @@ public class MyTaskScheduler {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
@Scheduled(cron = "0 0 9 * * ?")
|
||||
public void sendTrialOrderExcelToManagements() {
|
||||
// 获取前一天日期
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
// LocalDate before = LocalDate.now().minusDays(4);
|
||||
|
||||
// 查询前一天的试用订单
|
||||
QueryWrapper<TrialOrder> qw = new QueryWrapper<>();
|
||||
@@ -111,7 +131,9 @@ public class MyTaskScheduler {
|
||||
row.createCell(6).setCellValue(trialOrder.getCountry());
|
||||
row.createCell(7).setCellValue(trialOrder.getOccupation());
|
||||
row.createCell(8).setCellValue(trialOrder.getCreateTime().format(formatter));
|
||||
row.createCell(9).setCellValue(trialOrder.getUpdateTime().format(formatter));
|
||||
if (!ObjectUtils.isEmpty(trialOrder.getUpdateTime())) {
|
||||
row.createCell(9).setCellValue(trialOrder.getUpdateTime().format(formatter));
|
||||
}
|
||||
row.createCell(10).setCellValue(trialOrder.getStatus());
|
||||
}
|
||||
|
||||
@@ -119,14 +141,258 @@ public class MyTaskScheduler {
|
||||
String fileName = "trialOrder-" + yesterday.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
||||
try (FileOutputStream fileOut = new FileOutputStream(fileName)) {
|
||||
workbook.write(fileOut);
|
||||
SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
// SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
// SendEmailUtil.sendExcelEmail("ningning@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("johnnyho@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("ringolau@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("chelseayu@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
// SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null);
|
||||
SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null);
|
||||
// SendEmailUtil.sendNoExcelEmail("ningning@code-create.com.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("johnnyho@code-create.com.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("ringolau@code-create.com.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("chelseayu@code-create.com.hk", null);
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private UserLikeGroupMapper userLikeGroupMapper;
|
||||
@Resource
|
||||
private UserLikeMapper userLikeMapper;
|
||||
@Resource
|
||||
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
||||
@Resource
|
||||
private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
|
||||
@Resource
|
||||
private DesignItemMapper designItemMapper;
|
||||
@Resource
|
||||
private DesignItemDetailMapper designItemDetailMapper;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
public void clearMinio() {
|
||||
// 获取当前所有history
|
||||
QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
||||
List<UserLikeGroup> userLikeGroupList = userLikeGroupMapper.selectList(userLikeGroupQueryWrapper);
|
||||
List<Long> userLikeGroupIdList = userLikeGroupList.stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
||||
QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
|
||||
userLikeQueryWrapper.lambda().in(UserLike::getUserLikeGroupId, userLikeGroupIdList);
|
||||
// 所有喜欢的图片
|
||||
List<UserLike> userLikes = userLikeMapper.selectList(userLikeQueryWrapper);
|
||||
List<Long> designOutfitIdList = userLikes.stream().map(UserLike::getDesignOutfitId).collect(Collectors.toList());
|
||||
QueryWrapper<TDesignPythonOutfit> designPythonOutfitQueryWrapper = new QueryWrapper<>();
|
||||
designPythonOutfitQueryWrapper.lambda().notIn(TDesignPythonOutfit::getId, designOutfitIdList);
|
||||
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(designPythonOutfitQueryWrapper);
|
||||
// int i = 0;
|
||||
// for (TDesignPythonOutfit tDesignPythonOutfit : tDesignPythonOutfits) {
|
||||
// String designUrl = tDesignPythonOutfit.getDesignUrl();
|
||||
// if (StringUtils.isNotBlank(designUrl)) {
|
||||
// minioUtil.deleteObject(designUrl);
|
||||
// i ++;
|
||||
// }
|
||||
// QueryWrapper<TDesignPythonOutfitDetail> designPythonOutfitDetailQueryWrapper = new QueryWrapper<>();
|
||||
// designPythonOutfitDetailQueryWrapper.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, tDesignPythonOutfit.getId());
|
||||
// List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(designPythonOutfitDetailQueryWrapper);
|
||||
// for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||
// if (!tDesignPythonOutfitDetail.getImageCategory().equals("body")) {
|
||||
// if (StringUtils.isNotBlank(tDesignPythonOutfitDetail.getImageUrl())) {
|
||||
// minioUtil.deleteObject(tDesignPythonOutfitDetail.getImageUrl());
|
||||
// i ++;
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(tDesignPythonOutfitDetail.getMaskUrl())) {
|
||||
// minioUtil.deleteObject(tDesignPythonOutfitDetail.getMaskUrl());
|
||||
// i ++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
System.out.println("i");
|
||||
// List<Long> designItemIdList = userLikes.stream().map(UserLike::getDesignItemId).collect(Collectors.toList());
|
||||
// QueryWrapper<DesignItem> designItemQueryWrapper = new QueryWrapper<>();
|
||||
// designItemQueryWrapper.lambda().in(DesignItem::getId,designItemIdList);
|
||||
// List<DesignItem> designItems = designItemMapper.selectList(designItemQueryWrapper);
|
||||
// for (DesignItem designItem : designItems) {
|
||||
// QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||
// designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItem.getId());
|
||||
// List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||
// for (DesignItemDetail designItemDetail : designItemDetails) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Resource
|
||||
private AttributeRetrievalMapper attributeRetrievalMapper;
|
||||
|
||||
public void addSystemFileStyle() {
|
||||
// ExecutorService executorService = Executors.newFixedThreadPool(5);
|
||||
|
||||
// try {
|
||||
// String[] filePaths = {
|
||||
// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens bottom style output.xlsx",
|
||||
// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens outer style output.xlsx",
|
||||
// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens top style output.xlsx"
|
||||
//// "/workspace/shb/Mens_bottom_style_output.xlsx",
|
||||
//// "/workspace/shb/Mens_outer_style_output.xlsx",
|
||||
//// "/workspace/shb/Mens_top_style_output.xlsx"
|
||||
// };
|
||||
//
|
||||
// for (String filePath : filePaths) {
|
||||
//// executorService.submit(() -> processExcelFile(filePath));
|
||||
// processExcelFile(filePath);
|
||||
// }
|
||||
// }catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
// } finally {
|
||||
// executorService.shutdown();
|
||||
// try {
|
||||
// if (!executorService.awaitTermination(60, TimeUnit.MINUTES)) {
|
||||
// executorService.shutdownNow();
|
||||
// }
|
||||
// } catch (InterruptedException e) {
|
||||
// executorService.shutdownNow();
|
||||
// }
|
||||
// }
|
||||
String[] filePaths = {
|
||||
"C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens bottom style output.xlsx",
|
||||
"C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens outer style output.xlsx",
|
||||
"C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens top style output.xlsx"
|
||||
// "/workspace/shb/Mens_bottom_style_output.xlsx",
|
||||
// "/workspace/shb/Mens_outer_style_output.xlsx",
|
||||
// "/workspace/shb/Mens_top_style_output.xlsx"
|
||||
};
|
||||
|
||||
for (String filePath : filePaths) {
|
||||
// executorService.submit(() -> processExcelFile(filePath));
|
||||
processExcelFile(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
private void processExcelFile(String filePath) {
|
||||
System.out.println("线程开始");
|
||||
try {
|
||||
List<List<String>> excelData = ExcelReader.readExcel(filePath);
|
||||
String tableName = getTableNameFromFilePath(filePath);
|
||||
String prefix = getPrefixFromFilePath(filePath);
|
||||
|
||||
for (List<String> columnData : excelData) {
|
||||
String style = columnData.get(0);
|
||||
for (int i = 1; i < columnData.size(); i++) {
|
||||
String fileName = columnData.get(i);
|
||||
if (StringUtils.isBlank(fileName)) {
|
||||
continue;
|
||||
}
|
||||
if ("X".equals(style)) {
|
||||
attributeRetrievalMapper.updateStyleByFileName("X", prefix + fileName, tableName);
|
||||
System.out.println(fileName);
|
||||
} else {
|
||||
// if (style.equals("Y2K 风")) {
|
||||
// StyleEnum.COUNTRY_STYLE
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }else if (style.equals("")) {
|
||||
//
|
||||
// }
|
||||
attributeRetrievalMapper.updateStyleByFileName(style, prefix + fileName, tableName);
|
||||
System.out.println(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getTableNameFromFilePath(String filePath) {
|
||||
if (filePath.contains("Blouse")) {
|
||||
return "female_top";
|
||||
} else if (filePath.contains("Dress")) {
|
||||
return "female_dress";
|
||||
} else if (filePath.contains("Outerwear")) {
|
||||
return "female_outwear";
|
||||
} else if (filePath.contains("Skirt")) {
|
||||
return "female_skirt";
|
||||
} else if (filePath.contains("Trousers")) {
|
||||
return "female_pants";
|
||||
} else if (filePath.contains("bottom")) {
|
||||
return "male_bottom";
|
||||
} else if (filePath.contains("outer")) {
|
||||
return "male_outwear";
|
||||
} else if (filePath.contains("top")) {
|
||||
return "male_top";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getPrefixFromFilePath(String filePath) {
|
||||
if (filePath.contains("Blouse")) {
|
||||
return "blouse/";
|
||||
} else if (filePath.contains("Dress")) {
|
||||
return "dress/";
|
||||
} else if (filePath.contains("Outerwear")) {
|
||||
return "outwear/";
|
||||
} else if (filePath.contains("Skirt")) {
|
||||
return "skirt/";
|
||||
} else if (filePath.contains("Trousers")) {
|
||||
return "trousers/";
|
||||
} else if (filePath.contains("bottom")) {
|
||||
return "bottom/";
|
||||
} else if (filePath.contains("outer")) {
|
||||
return "outer/";
|
||||
} else if (filePath.contains("top")) {
|
||||
return "top/";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// public static List<String> getFileNames(String directoryPath) {
|
||||
// List<String> fileNames = new ArrayList<>();
|
||||
// Path path = Paths.get(directoryPath);
|
||||
//
|
||||
// try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
|
||||
// for (Path entry : stream) {
|
||||
// if (Files.isRegularFile(entry)) {
|
||||
// fileNames.add(entry.getFileName().toString());
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// System.err.println("Error reading directory: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// return fileNames;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -3,17 +3,12 @@ package com.ai.da.common.config;
|
||||
import com.paypal.core.PayPalEnvironment;
|
||||
import com.paypal.core.PayPalHttpClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@PropertySource("classpath:paypal-sandbox.properties")
|
||||
@PropertySource("classpath:payment.properties")
|
||||
public class PayPalClient {
|
||||
|
||||
public PayPalHttpClient client(String mode, String clientId, String clientSecret) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.ai.da.common.config.exception;
|
||||
|
||||
public class TokenMissingOrExpiredException extends RuntimeException {
|
||||
public TokenMissingOrExpiredException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ai.da.common.constant;
|
||||
|
||||
public class AlipayHKConstant {
|
||||
|
||||
// 服务名
|
||||
public static final String CREATE_ORDER = "create_order";
|
||||
public static final String ORDER_DETAILS = "order_details";
|
||||
public static final String TRANSACTION_DETAILS = "transaction_details";
|
||||
public static final String GET_FILE = "get_file";
|
||||
public static final String CREATE_AUTO_DEBIT = "create_auto_debit";
|
||||
public static final String REFRESH_TRANSACTION_STATUS = "refresh_transaction_status";
|
||||
public static final String REFUND_TRANSACTION = "refund_transaction";
|
||||
|
||||
// 订单状态
|
||||
public static final String STATUS_NEW = "new";
|
||||
public static final String STATUS_WAIT = "wait";
|
||||
public static final String STATUS_PAID = "paid";
|
||||
public static final String STATUS_EXPIRED = "expired";
|
||||
public static final String STATUS_LIQUIDATED = "liquidated";
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.ai.da.common.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommonConstant {
|
||||
// 单位 秒 10分钟过期
|
||||
// public static final Long TASK_EXPIRE_TIME = 24 * 60 * 60L;
|
||||
@@ -10,5 +13,75 @@ public class CommonConstant {
|
||||
public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60;
|
||||
// 单位 秒 一天过期 in redis
|
||||
public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L;
|
||||
// 单位 秒 7天过期
|
||||
public static final Long REDIS_SET_EXPIRE_TIME = 24 * 60 * 60 * 7L;
|
||||
|
||||
public static class Numbers{
|
||||
public static final Integer NUMBER_10 = 10;
|
||||
public static final Integer NUMBER_1000 = 1000;
|
||||
public static final Integer NUMBER_10080 = 10080;
|
||||
}
|
||||
|
||||
public static final String GENERATE_PATH = "/api/generate_image";
|
||||
|
||||
public static final String GENERATE_SINGLE_LOGO = "/api/generate_single_logo";
|
||||
|
||||
public static final String GENERATE_SLOGAN = "/api/slogan";
|
||||
|
||||
public static final String GENERATE_CANCEL = "/api/generate_cancel/";
|
||||
|
||||
public static final String GENERATE_LOGO_SINGLE_CANCEL = "/api/generate_single_logo_cancel/";
|
||||
|
||||
public static final String PYTHON_PORT_9996 = "9996";
|
||||
|
||||
public static final String PYTHON_PORT_9997 = "9997";
|
||||
|
||||
public static final List<String> AGES_EN = Arrays.asList("Below 20", "20-30", "30-40", "40+");
|
||||
|
||||
public static final List<String> AGES_CN = Arrays.asList("20岁以下", "20-30岁", "30-40岁", "40+岁");
|
||||
public static final List<String> IF_HELPFUL_EN = Arrays.asList("Easy to learn and use", "Easy to get trend information",
|
||||
"Lots of creative design proposals","The AIGC functions for moodboard is helpful","The AIGC functions for design sketches is helpful",
|
||||
"Easy to select the right color","The Chatbot function is helpful","The print position function is helpful",
|
||||
"The drawing function is helpful","The export function is useful","Easy to edit the design","Others");
|
||||
|
||||
public static final List<String> IF_HELPFUL_CN = Arrays.asList("易于学习和使用", "容易获取趋势信息",
|
||||
"提供大量创意设计方案","AIGC功能对灵感板有帮助","AIGC功能对设计草图有帮助",
|
||||
"容易选择合适的颜色","聊天机器人功能有帮助","打印位置功能有帮助",
|
||||
"绘图功能有帮助","导出功能有用","设计编辑简单","其他");
|
||||
|
||||
public static final List<String> IF_IMPROVE_EN = Arrays.asList("Proposed designs are boring, need more interesting designs",
|
||||
"Difficult to make changes on design","Only 2D output, no 3D results","Difficult to apply keywords for AIGC generation",
|
||||
"Clothing is not in the right proportion","Not compatible with pattern making solutions","Improved user interface for better navigation",
|
||||
"Lack of responsive customer support","Insufficient tutorial or guidance for new users","Limited personalization options for designs","Others");
|
||||
|
||||
public static final List<String> IF_IMPROVE_CN = Arrays.asList("提供的设计很无聊,需要更多有趣的设计",
|
||||
"设计修改困难","只有2D输出,没有3D结果","难以选择合适的关键词应用于AIGC生成",
|
||||
"服装比例不正确","与打版解决方案不兼容","改进用户界面以便更好导航",
|
||||
"客户支持响应不及时","对新用户的教程或指导不足","设计个性化选项有限","其他");
|
||||
|
||||
public static final List<String> IS_SUBSCRIBE = Arrays.asList("yes", "no");
|
||||
|
||||
// public static final String DEFAULT_AVATAR = "aida-users/87/avatar/default.jpg";
|
||||
public static final String DEFAULT_AVATAR = "aida-users/87/avatar/default.png";
|
||||
|
||||
/* 截止至2024/08/26,在Code-Create DB中pmr_users表中最大的用户id */
|
||||
public static final Long MAXIMUM_USER_ID = 704L;
|
||||
// public static final Long MAXIMUM_USER_ID = 225L;
|
||||
|
||||
// 激活更改邮箱 链接有效期 毫秒 3天
|
||||
public static final Long CHANGE_MAILBOX_LINK_VALIDITY = 259200000L;
|
||||
|
||||
public static final String RCA_WORKSHOP_TAG = "#RCAworkshop_2024";
|
||||
|
||||
public static final String PORTFOLIO_DELETED_EN = "Portfolio has been deleted";
|
||||
|
||||
public static final String PORTFOLIO_DELETED_CN = "作品已删除";
|
||||
|
||||
public static final String TIME_FORMAT_MMM_dd_yyyy_EEEE = "MMM. dd, yyyy, EEEE";
|
||||
|
||||
public static final String TIME_FORMAT_MMM_dd_yyyy = "MMM. dd, yyyy";
|
||||
|
||||
public static final String TIME_FORMAT_yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static final String AFFILIATE_LINK = "https://www.aida.com.hk?ref=";
|
||||
}
|
||||
|
||||
@@ -23,7 +23,17 @@ public enum AuthenticationOperationTypeEnum {
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
FORGET_PWD;
|
||||
FORGET_PWD,
|
||||
/**
|
||||
* 更改邮箱
|
||||
*/
|
||||
CHANGE_MAILBOX,
|
||||
/**
|
||||
* 填写用户国家和职业
|
||||
*/
|
||||
UPDATE_USERINFO,
|
||||
|
||||
REGISTER;
|
||||
|
||||
public static AuthenticationOperationTypeEnum of(String name) {
|
||||
return Stream.of(AuthenticationOperationTypeEnum.values()).filter(v -> v.name().equals(name)).findFirst().orElse(null);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@@ -36,7 +38,18 @@ public enum CollectionLevel2TypeEnum {
|
||||
* 男装下装
|
||||
*/
|
||||
BOTTOMS("Bottoms"),
|
||||
;
|
||||
/**
|
||||
* 印花-logo
|
||||
*/
|
||||
LOGO("Logo"),
|
||||
/**
|
||||
* 印花-slogan
|
||||
*/
|
||||
SLOGAN("Slogan"),
|
||||
/**
|
||||
* 印花-图案
|
||||
*/
|
||||
Pattern("Pattern");
|
||||
|
||||
private String realName;
|
||||
|
||||
@@ -51,4 +64,8 @@ public enum CollectionLevel2TypeEnum {
|
||||
public static CollectionLevel2TypeEnum of(String realName) {
|
||||
return Stream.of(CollectionLevel2TypeEnum.values()).filter(v -> v.getRealName().equals(realName)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static List<String> printType() {
|
||||
return Arrays.asList(LOGO.getRealName(), SLOGAN.getRealName(), Pattern.getRealName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,19 +8,35 @@ import lombok.Getter;
|
||||
public enum CreditsEventsEnum {
|
||||
|
||||
PRICE("price","6"),
|
||||
// PRICE("price","1"),// for test
|
||||
// PRICE("price","0.1"),
|
||||
|
||||
BUY_CREDITS("Buy Credits","600"),
|
||||
BUY_CREDITS("Buy Credits","60"),
|
||||
// BUY_CREDITS("Buy Credits","10"),// for test
|
||||
|
||||
INIT("init", "500"),
|
||||
REFUND("Refund","60"),
|
||||
// BUY_CREDITS("Buy Credits","10"),
|
||||
|
||||
DAILY_CHECKIN("Daily Check-In", "20"),
|
||||
// 每月更新
|
||||
INIT_YEARLY("init_yearly", "6000"),
|
||||
INIT_MONTHLY("init_monthly", "5000"),
|
||||
INIT_TRIAL("init_trial", "100"),
|
||||
INIT_WEEKLY("init_weekly","6000"),
|
||||
RESET_YEAR_CREDITS("reset_year_credits","6000"),
|
||||
|
||||
SOCIAL_MEDIA_SHARING("Social Media Sharing","20"),
|
||||
// SUPER_RESOLUTION("Super Resolution","30"),
|
||||
SUPER_RESOLUTION("Super Resolution","10"),
|
||||
SLOGAN("Slogan","10"),
|
||||
LOGO("Logo","5"),
|
||||
PATTERN("Pattern","5"),
|
||||
MOOD_BOARD("MoodBoard","5"),
|
||||
SKETCH_BOARD("SketchBoard","5"),
|
||||
TO_PRODUCT_IMAGE("ToProductImage","5"),
|
||||
RELIGHT("Relight","5"),
|
||||
QUESTIONNAIRE("Questionnaire","100"),
|
||||
IMAGE_TO_SKETCH("ImageToSketch","5"),
|
||||
|
||||
// SUPER_RESOLUTION("Super Resolution","300"),
|
||||
SUPER_RESOLUTION("Super Resolution","5"),
|
||||
|
||||
OTHER("Other","10");
|
||||
OTHER("Other","5");
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ public enum LibraryLevel1TypeEnum {
|
||||
/**
|
||||
* 模特
|
||||
*/
|
||||
MODELS("Models");
|
||||
MODELS("Models"),
|
||||
DESIGN_ELEMENTS("DesignElements");
|
||||
|
||||
private String realName;
|
||||
|
||||
|
||||
@@ -10,38 +10,34 @@ public enum OrderStatusEnum {
|
||||
* 未支付
|
||||
*/
|
||||
NOT_PAY("未支付"),
|
||||
|
||||
|
||||
/**
|
||||
* 支付成功
|
||||
*/
|
||||
SUCCESS("支付成功"),
|
||||
|
||||
/**
|
||||
* 支付失败
|
||||
*/
|
||||
FAILURE("支付失败"),
|
||||
/**
|
||||
* 已关闭
|
||||
*/
|
||||
TIMEOUT_CLOSED("超时已关闭"),
|
||||
|
||||
/**
|
||||
* 已取消
|
||||
*/
|
||||
CANCEL("用户已取消"),
|
||||
|
||||
/**
|
||||
* 退款中
|
||||
*/
|
||||
REFUND_PROCESSING("退款中"),
|
||||
|
||||
/**
|
||||
* 已退款
|
||||
*/
|
||||
REFUND_SUCCESS("已退款"),
|
||||
|
||||
/**
|
||||
* 退款异常
|
||||
*/
|
||||
REFUND_ABNORMAL("退款异常"),
|
||||
|
||||
/**
|
||||
* paypal订单状态为 APPROVED
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,17 @@ public enum PayTypeEnum {
|
||||
/**
|
||||
* PayPal
|
||||
*/
|
||||
PAYPAL("PayPal");
|
||||
PAYPAL("PayPal"),
|
||||
|
||||
/**
|
||||
* 香港支付宝
|
||||
*/
|
||||
ALIPAY_HK("Alipay-HK"),
|
||||
|
||||
/**
|
||||
* Stripe
|
||||
*/
|
||||
STRIPE("Stripe");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
|
||||
25
src/main/java/com/ai/da/common/enums/ProductEnum.java
Normal file
25
src/main/java/com/ai/da/common/enums/ProductEnum.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProductEnum {
|
||||
// 积分购买
|
||||
CreditsProduct("AiDA credits purchase", 6L),
|
||||
// 年度订阅
|
||||
AnnualSubscription("AiDA Annual Subscription", 5000L),
|
||||
// 月度订阅
|
||||
MonthlySubscription("AiDA Monthly Subscription", 500L),
|
||||
// 测试
|
||||
DailySubscription("AiDA Daily Subscription", 10L),
|
||||
;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
private final Long price;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ai.da.common.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel("交易记录分页响应结果")
|
||||
public class TransactionPageResponse<T> extends PageBaseResponse<T> {
|
||||
|
||||
private BigDecimal totalAmount;
|
||||
}
|
||||
@@ -1,127 +1,139 @@
|
||||
package com.ai.da.common.security.filter;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.security.config.SecurityProperties;
|
||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||
import com.ai.da.common.utils.LocalCacheUtils;
|
||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
||||
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
||||
import com.ai.da.common.utils.RequestInfoUtil;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.security.sasl.AuthenticationException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: dangweijian
|
||||
* @description: 认证拦截器
|
||||
* @create: 2020-07-10 16:50
|
||||
**/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
@Resource
|
||||
private JWTTokenHelper jwtTokenHelper;
|
||||
@Resource
|
||||
private SecurityProperties properties;
|
||||
|
||||
private static final List<String> FILTER_URL =
|
||||
Arrays.asList("/favicon.ico", "/doc.html", "api/account/login", "api/account/preLogin", "api/account/sendEmail","api/account/noLoginRequired",
|
||||
"/webjars/", "/swagger-resources", "/v2/api-docs", "api/account/resetPwd",
|
||||
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
|
||||
"/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
|
||||
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew",
|
||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
||||
// "/api/python/chatStream",
|
||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back"
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {
|
||||
String requestURI = httpServletRequest.getRequestURI();
|
||||
|
||||
if (calculateUrl(requestURI)) {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
HttpServletRequest wrappedRequest = httpServletRequest;
|
||||
HttpServletResponse wrappedResponse = httpServletResponse;
|
||||
try {
|
||||
stopWatch.start();
|
||||
if ((httpServletRequest.getContentType() == null && httpServletRequest.getContentLength() > 0) || (httpServletRequest.getContentType() != null && !httpServletRequest.getContentType().contains("application/json"))) {
|
||||
extracted(wrappedRequest);
|
||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
||||
} else {
|
||||
wrappedRequest = new MultiReadHttpServletRequest(httpServletRequest);
|
||||
wrappedResponse = new MultiReadHttpServletResponse(httpServletResponse);
|
||||
extracted(wrappedRequest);
|
||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SecurityContextHolder.clearContext();
|
||||
throw e;
|
||||
} finally {
|
||||
stopWatch.stop();
|
||||
}
|
||||
} else {
|
||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean calculateUrl(String requestURI) {
|
||||
String filterUrl = FILTER_URL.stream().filter(url -> requestURI.contains(url)).findFirst().orElse(null);
|
||||
return null == filterUrl ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
|
||||
private void extracted(HttpServletRequest request) throws AuthenticationException {
|
||||
String jwtToken = request.getHeader(properties.getJwtTokenHeader());
|
||||
log.debug("后台检查令牌:{}", jwtToken);
|
||||
|
||||
if (StrUtil.isBlank(jwtToken)) {
|
||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
||||
log.info("本次请求的ip为 : " + ipAddress);
|
||||
throw new RuntimeException("请传入token!");
|
||||
}
|
||||
if(jwtToken.equals("Bearer-eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIyIiwic3ViIjoie1wiaWRcIjoyLFwidXNlcm5hbWVcIjpcImxpcnNcIn0iLCJpYXQiOjE2NjU3NDEwODcsImlzcyI6IkRXSiIsImF1dGhvcml0aWVzIjoiW10iLCJleHAiOjE2NzQzODEwODd9.ShM9R_NNFD7oo1OvxrEgg7PFeWinOuAKkuInUCMQupp66s64Hhv8tN0Wwr83nIN4rHPqtn95wmd4msWcvaFYJA")){
|
||||
//写死 暂时放行
|
||||
return;
|
||||
}
|
||||
// 检查token
|
||||
boolean validate = jwtTokenHelper.validateToken(jwtToken);
|
||||
if (validate) {
|
||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(jwtToken);
|
||||
if (principal == null) {
|
||||
throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||
}
|
||||
//先清空当前线程变量,防止上一个线程遗留
|
||||
UserContext.delete();
|
||||
//存取用户信息到缓存
|
||||
UserContext.setUserHolder(principal);
|
||||
//校验token
|
||||
String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId()));
|
||||
|
||||
if(StringUtils.isEmpty(cacheToken)){
|
||||
throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||
}
|
||||
if(!cacheToken.equals(jwtToken) ){
|
||||
throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||
}
|
||||
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(null, null);
|
||||
// SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.ai.da.common.security.filter;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ai.da.common.config.exception.TokenMissingOrExpiredException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.security.config.SecurityProperties;
|
||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||
import com.ai.da.common.utils.LocalCacheUtils;
|
||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
||||
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
||||
import com.ai.da.common.utils.RequestInfoUtil;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.security.sasl.AuthenticationException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: dangweijian
|
||||
* @description: 认证拦截器
|
||||
* @create: 2020-07-10 16:50
|
||||
**/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
@Resource
|
||||
private JWTTokenHelper jwtTokenHelper;
|
||||
@Resource
|
||||
private SecurityProperties properties;
|
||||
|
||||
private static final List<String> FILTER_URL =
|
||||
Arrays.asList("/favicon.ico", "/doc.html", "api/account/login", "api/account/preLogin", "api/account/sendEmail","api/account/noLoginRequired",
|
||||
"/webjars/", "/swagger-resources", "/v2/api-docs", "api/account/resetPwd",
|
||||
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
|
||||
"/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
|
||||
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew","/api/third/party/updateNoLoginRequiredNew",
|
||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
|
||||
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
|
||||
"/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify",
|
||||
"/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback","/api/third/party/parseGoogleCredential","/api/third/party/receiveDesignResults","/api/third/party/parseWeChatCode"
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest httpServletRequest, @NonNull HttpServletResponse httpServletResponse, @NonNull FilterChain filterChain) throws ServletException, IOException {
|
||||
String requestURI = httpServletRequest.getRequestURI();
|
||||
|
||||
if (calculateUrl(requestURI) || hasAuthorizationToken(httpServletRequest)) {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
HttpServletRequest wrappedRequest = httpServletRequest;
|
||||
HttpServletResponse wrappedResponse = httpServletResponse;
|
||||
try {
|
||||
stopWatch.start();
|
||||
if ((httpServletRequest.getContentType() == null && httpServletRequest.getContentLength() > 0) || (httpServletRequest.getContentType() != null && !httpServletRequest.getContentType().contains("application/json"))) {
|
||||
extracted(wrappedRequest);
|
||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
||||
} else {
|
||||
wrappedRequest = new MultiReadHttpServletRequest(httpServletRequest);
|
||||
wrappedResponse = new MultiReadHttpServletResponse(httpServletResponse);
|
||||
extracted(wrappedRequest);
|
||||
filterChain.doFilter(wrappedRequest, wrappedResponse);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SecurityContextHolder.clearContext();
|
||||
throw e;
|
||||
} finally {
|
||||
stopWatch.stop();
|
||||
}
|
||||
} else {
|
||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean calculateUrl(String requestURI) {
|
||||
String filterUrl = FILTER_URL.stream().filter(url -> requestURI.contains(url)).findFirst().orElse(null);
|
||||
return null == filterUrl ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
|
||||
private boolean hasAuthorizationToken(HttpServletRequest request) {
|
||||
String authorizationHeader = request.getHeader("Authorization");
|
||||
return authorizationHeader != null && authorizationHeader.startsWith("Bearer");
|
||||
}
|
||||
|
||||
private void extracted(HttpServletRequest request) throws AuthenticationException {
|
||||
String jwtToken = request.getHeader(properties.getJwtTokenHeader());
|
||||
// log.debug("后台检查令牌:{}", jwtToken);
|
||||
|
||||
if (StrUtil.isBlank(jwtToken)) {
|
||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
||||
log.info("本次请求的ip为 : " + ipAddress);
|
||||
// throw new RuntimeException("请传入token!");
|
||||
throw new TokenMissingOrExpiredException("请传入token!");
|
||||
}
|
||||
if(jwtToken.equals("Bearer-eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIyIiwic3ViIjoie1wiaWRcIjoyLFwidXNlcm5hbWVcIjpcImxpcnNcIn0iLCJpYXQiOjE2NjU3NDEwODcsImlzcyI6IkRXSiIsImF1dGhvcml0aWVzIjoiW10iLCJleHAiOjE2NzQzODEwODd9.ShM9R_NNFD7oo1OvxrEgg7PFeWinOuAKkuInUCMQupp66s64Hhv8tN0Wwr83nIN4rHPqtn95wmd4msWcvaFYJA")){
|
||||
//写死 暂时放行
|
||||
return;
|
||||
}
|
||||
// 检查token
|
||||
boolean validate = jwtTokenHelper.validateToken(jwtToken);
|
||||
if (validate) {
|
||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(jwtToken);
|
||||
if (principal == null) {
|
||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(token without userInfo)");
|
||||
}
|
||||
//先清空当前线程变量,防止上一个线程遗留
|
||||
UserContext.delete();
|
||||
//存取用户信息到缓存
|
||||
UserContext.setUserHolder(principal);
|
||||
//校验token
|
||||
String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId()));
|
||||
|
||||
if(StringUtils.isEmpty(cacheToken)){
|
||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(local cache empty)");
|
||||
}
|
||||
if(!cacheToken.equals(jwtToken) ){
|
||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(token not match local cache)");
|
||||
}
|
||||
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(null, null);
|
||||
// SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ai.da.common.security.jwt;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.security.config.SecurityProperties;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -30,6 +31,7 @@ public class JWTTokenHelper {
|
||||
|
||||
private static final String ISSUER = "DWJ";
|
||||
private static final String AUTHORITIES = "authorities";
|
||||
private static final String CHANGE_MAILBOX = "changeMailbox";
|
||||
|
||||
public String createToken(AuthPrincipalVo principal) {
|
||||
String token = Jwts.builder()
|
||||
@@ -65,4 +67,21 @@ public class JWTTokenHelper {
|
||||
token = token.replaceAll(securityProperties.getJwtTokenPrefix(), "");
|
||||
return Jwts.parser().setSigningKey(securityProperties.getJwtSecret()).parseClaimsJws(token).getBody();
|
||||
}
|
||||
|
||||
public String createToken(Long userId, String userEmail){
|
||||
String token = Jwts.builder()
|
||||
.setId(String.valueOf(userId))
|
||||
.setSubject(userEmail + "_" + userId)
|
||||
.setIssuedAt(new Date())
|
||||
.setIssuer(ISSUER)
|
||||
.claim(CHANGE_MAILBOX, JSON.toJSONString(new ArrayList<>()))//自定义属性 权限
|
||||
.setExpiration(new Date(System.currentTimeMillis() + CommonConstant.CHANGE_MAILBOX_LINK_VALIDITY))
|
||||
.signWith(SignatureAlgorithm.HS256, securityProperties.getJwtSecret())
|
||||
.compact();
|
||||
return token;
|
||||
}
|
||||
|
||||
public String parseToEmailAndId(String token) {
|
||||
return parser(token).getSubject();
|
||||
}
|
||||
}
|
||||
|
||||
83
src/main/java/com/ai/da/common/task/AccountTask.java
Normal file
83
src/main/java/com/ai/da/common/task/AccountTask.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.service.AccountService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AccountTask {
|
||||
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 每周日晚上刷新 年付用户、月付用户的积分
|
||||
* 替换为
|
||||
* 每个月月初只刷新年付用户的积分
|
||||
*/
|
||||
// @Scheduled(cron = "59 59 23 * * ?")
|
||||
@Scheduled(cron = "0 0 0 1 * ?")
|
||||
public void refreshCreditsMonthly() {
|
||||
log.info("每月1号0点 将年费用户积分重置为 6000");
|
||||
accountService.refreshCreditsWeekly();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
public void getPaidUser() {
|
||||
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
||||
accountService.extendValidityForCC();
|
||||
}
|
||||
|
||||
// 每天凌晨0点执行一次
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void cancelActivityBenefits() {
|
||||
// 1、查询当前所有参与了活动且过期的用户
|
||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);
|
||||
|
||||
// 2、将到期用户置为游客
|
||||
for (Account account : accountList) {
|
||||
log.info("参与活动的用户{} : {} 于 {} 账号有效期到期,置为游客", account.getId(), account.getUserEmail(), account.getValidEndTime());
|
||||
accountService.toVisitor(account);
|
||||
}
|
||||
}
|
||||
|
||||
// 每天检测正式用户到期情况,每天凌晨0点执行
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void paidUserToVisitor() {
|
||||
// 1、查询当前已过期正式用户或试用用户
|
||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
||||
accountList.addAll(accountService.getExpiredUserBySystemUser(2));
|
||||
accountList.addAll(accountService.getExpiredUserBySystemUser(3));
|
||||
|
||||
// 2、将到期用户置为游客
|
||||
for (Account account : accountList) {
|
||||
log.info("用户{} : {} 于 {}账号有效期到期,置为游客", account.getId(), account.getUserEmail(), account.getValidEndTime());
|
||||
accountService.toVisitor(account);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !!关闭此定时器!!不再从Code-Create上默认创建AiDA游客
|
||||
* 将Code-Create上注册的用户添加为AiDA的游客
|
||||
*/
|
||||
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
public void registerUserToVisitor() {
|
||||
accountService.registerUserToVisitor();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 0 1 * ?")
|
||||
// 每月初刷新所有用户用户名剩余修改次数
|
||||
public void resetUsernameModifyTimes(){
|
||||
log.info("重置所有用户的用户名修改次数");
|
||||
redisUtil.batchDeleteKeysWithSamePrefix(RedisUtil.NICKNAME_MODIFY_TIMES);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.common.enums.PayTypeEnum;
|
||||
import com.ai.da.service.AliPayService;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AliPayTask {
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private AliPayService aliPayService;
|
||||
|
||||
/**
|
||||
* 从第0秒开始每隔30秒执行1次,查询创建超过5分钟,并且未支付的订单
|
||||
*/
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirm(){
|
||||
|
||||
log.info("Alipay orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.ALIPAY.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
aliPayService.checkOrderStatus(orderNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class GenerateTask {
|
||||
|
||||
@Scheduled(cron = "0 0 */1 * * ?")
|
||||
public void generateScheduled(){
|
||||
log.info("测试定时器:generate");
|
||||
|
||||
try{
|
||||
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
216
src/main/java/com/ai/da/common/task/MoveDataScheduler.java
Normal file
216
src/main/java/com/ai/da/common/task/MoveDataScheduler.java
Normal file
@@ -0,0 +1,216 @@
|
||||
//package com.ai.da.common.task;
|
||||
//
|
||||
//import com.ai.da.common.utils.CopyUtil;
|
||||
//import com.ai.da.common.utils.ExcelReader;
|
||||
//import com.ai.da.common.utils.MinioUtil;
|
||||
//import com.ai.da.common.utils.SendEmailUtil;
|
||||
//import com.ai.da.mapper.primary.*;
|
||||
//import com.ai.da.mapper.primary.entity.*;
|
||||
//import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
||||
//import com.ai.da.mapper.third.*;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.apache.poi.ss.usermodel.Row;
|
||||
//import org.apache.poi.ss.usermodel.Sheet;
|
||||
//import org.apache.poi.ss.usermodel.Workbook;
|
||||
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.util.CollectionUtils;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import javax.annotation.Resource;
|
||||
//import java.io.FileOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.nio.file.Files;
|
||||
//import java.nio.file.Paths;
|
||||
//import java.time.LocalDate;
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.List;
|
||||
//import java.util.concurrent.ExecutorService;
|
||||
//import java.util.concurrent.Executors;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//@Component
|
||||
//public class MoveDataScheduler {
|
||||
//
|
||||
// @PostConstruct
|
||||
// public void test() {
|
||||
// moveData();
|
||||
// }
|
||||
//
|
||||
// @Resource
|
||||
// private UserLikeGroupMapper userLikeGroupMapper;
|
||||
// @Resource
|
||||
// private UserLikeGroupZSMapper userLikeGroupZSMapper;
|
||||
// @Resource
|
||||
// private UserLikeMapper userLikeMapper;
|
||||
// @Resource
|
||||
// private UserLikeZSMapper userLikeZSMapper;
|
||||
// @Resource
|
||||
// private CollectionElementMapper collectionElementMapper;
|
||||
// @Resource
|
||||
// private CollectionElementZSMapper collectionElementZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private CollectionMapper collectionMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private CollectionZSMapper collectionZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignMapper designMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignZSMapper designZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignItemMapper designItemMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignItemZSMapper designItemZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private TDesignPythonOutfitZSMapper designPythonOutfitZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private TDesignPythonOutfitDetailZSMapper designPythonOutfitDetailZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignItemDetailMapper designItemDetailMapper;
|
||||
// @Resource
|
||||
// private DesignItemZSDetailMapper designItemDetailZSMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignItemDetailPrintMapper designItemDetailPrintMapper;
|
||||
//
|
||||
// @Resource
|
||||
// private DesignItemDetailPrintZSMapper designItemDetailPrintZSMapper;
|
||||
//
|
||||
//
|
||||
// private void moveData() {
|
||||
// // 查询用户所有history记录
|
||||
// QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
||||
// userLikeGroupQueryWrapper.lambda().eq(UserLikeGroup::getAccountId, 11411);
|
||||
// List<UserLikeGroup> userLikeGroupList = userLikeGroupMapper.selectList(userLikeGroupQueryWrapper);
|
||||
//
|
||||
// for (UserLikeGroup userLikeGroup : userLikeGroupList) {
|
||||
//
|
||||
// com.ai.da.mapper.third.entity.UserLikeGroup userLikeGroupZS = CopyUtil.copyObject(userLikeGroup, com.ai.da.mapper.third.entity.UserLikeGroup.class);
|
||||
// userLikeGroupZS.setAccountId(11420L);
|
||||
// userLikeGroupZS.setId(null);
|
||||
// Collection collection = collectionMapper.selectById(userLikeGroup.getCollectionId());
|
||||
// com.ai.da.mapper.third.entity.Collection collectionZS = CopyUtil.copyObject(collection, com.ai.da.mapper.third.entity.Collection.class);
|
||||
// collectionZS.setAccountId(11420L);
|
||||
// collectionZS.setId(null);
|
||||
//
|
||||
// if (collection.getMoodTemplateId() != null) {
|
||||
// CollectionElement element = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
||||
// com.ai.da.mapper.third.entity.CollectionElement collectionElementZS = CopyUtil.copyObject(element, com.ai.da.mapper.third.entity.CollectionElement.class);
|
||||
// collectionElementZS.setAccountId(11420L);
|
||||
// collectionElementZS.setId(null);
|
||||
// collectionElementZSMapper.insert(collectionElementZS);
|
||||
// collectionZS.setMoodTemplateId(String.valueOf(collectionElementZS.getId()));
|
||||
// }
|
||||
// collectionZSMapper.insert(collectionZS);
|
||||
// userLikeGroupZS.setCollectionId(collectionZS.getId());
|
||||
// userLikeGroupZSMapper.insert(userLikeGroupZS);
|
||||
//
|
||||
// // 生成元素
|
||||
// QueryWrapper<CollectionElement> collectionElementQueryWrapper = new QueryWrapper<>();
|
||||
// collectionElementQueryWrapper.lambda().eq(CollectionElement::getCollectionId, userLikeGroup.getCollectionId());
|
||||
// List<CollectionElement> collectionElements = collectionElementMapper.selectList(collectionElementQueryWrapper);
|
||||
//
|
||||
// for (CollectionElement collectionElement : collectionElements) {
|
||||
// com.ai.da.mapper.third.entity.CollectionElement collectionElementZS = CopyUtil.copyObject(collectionElement, com.ai.da.mapper.third.entity.CollectionElement.class);
|
||||
// collectionElementZS.setId(null);
|
||||
// collectionElementZS.setAccountId(11420L);
|
||||
// collectionElementZS.setCollectionId(collectionZS.getId());
|
||||
// collectionElementZSMapper.insert(collectionElementZS);
|
||||
// }
|
||||
//
|
||||
// // 查询记录关联
|
||||
// QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
|
||||
// userLikeQueryWrapper.lambda().eq(UserLike::getUserLikeGroupId, userLikeGroup.getId());
|
||||
// List<UserLike> userLikes = userLikeMapper.selectList(userLikeQueryWrapper);
|
||||
// for (UserLike userLike : userLikes) {
|
||||
// Design design = designMapper.selectById(userLike.getDesignId());
|
||||
// com.ai.da.mapper.third.entity.Design designZS = CopyUtil.copyObject(design, com.ai.da.mapper.third.entity.Design.class);
|
||||
// designZS.setId(null);
|
||||
// designZS.setAccountId(11420L);
|
||||
// designZS.setCollectionId(collectionZS.getId());
|
||||
// designZSMapper.insert(designZS);
|
||||
//
|
||||
// com.ai.da.mapper.third.entity.UserLike userLikeZS = CopyUtil.copyObject(userLike, com.ai.da.mapper.third.entity.UserLike.class);
|
||||
//// Design design = designMapper.selectById(userLike.getDesignId());
|
||||
// userLikeZS.setId(null);
|
||||
// DesignItem designItem = designItemMapper.selectById(userLike.getDesignItemId());
|
||||
// com.ai.da.mapper.third.entity.DesignItem designItemZS = CopyUtil.copyObject(designItem, com.ai.da.mapper.third.entity.DesignItem.class);
|
||||
// designItemZS.setId(null);
|
||||
// designItemZS.setAccountId(11420L);
|
||||
// designItemZS.setDesignId(designZS.getId());
|
||||
// designItemZSMapper.insert(designItemZS);
|
||||
//
|
||||
// QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||
// designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItem.getId());
|
||||
// List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||
// for (DesignItemDetail designItemDetail : designItemDetails) {
|
||||
// com.ai.da.mapper.third.entity.DesignItemDetail designItemDetailZS = CopyUtil.copyObject(designItemDetail, com.ai.da.mapper.third.entity.DesignItemDetail.class);
|
||||
// designItemDetailZS.setId(null);
|
||||
// designItemDetailZS.setDesignItemId(designItemZS.getId());
|
||||
// designItemDetailZS.setAccountId(11420L);
|
||||
// designItemDetailZS.setDesignId(designZS.getId());
|
||||
// designItemDetailZSMapper.insert(designItemDetailZS);
|
||||
//
|
||||
// QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
||||
// designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetail.getId());
|
||||
// List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
||||
// if (!CollectionUtils.isEmpty(designItemDetailPrintList)) {
|
||||
// for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
||||
// com.ai.da.mapper.third.entity.DesignItemDetailPrint designItemDetailPrintZS = CopyUtil.copyObject(designItemDetailPrint, com.ai.da.mapper.third.entity.DesignItemDetailPrint.class);
|
||||
// designItemDetailPrintZS.setId(null);
|
||||
// designItemDetailPrintZS.setDesignItemDetailId(designItemDetailZS.getId());
|
||||
// designItemDetailPrintZSMapper.insert(designItemDetailPrintZS);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// userLikeZS.setDesignItemId(designItemZS.getId());
|
||||
// TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId());
|
||||
// com.ai.da.mapper.third.entity.TDesignPythonOutfit tDesignPythonOutfitZS = CopyUtil.copyObject(tDesignPythonOutfit, com.ai.da.mapper.third.entity.TDesignPythonOutfit.class);
|
||||
// tDesignPythonOutfitZS.setId(null);
|
||||
// tDesignPythonOutfitZS.setDesignItemId(designItemZS.getId());
|
||||
// tDesignPythonOutfitZS.setCollectionId(collectionZS.getId());
|
||||
// tDesignPythonOutfitZS.setUserId(11420L);
|
||||
// tDesignPythonOutfitZS.setDesignId(designZS.getId());
|
||||
// designPythonOutfitZSMapper.insert(tDesignPythonOutfitZS);
|
||||
//
|
||||
// userLikeZS.setUserLikeGroupId(userLikeGroupZS.getId());
|
||||
// userLikeZS.setDesignId(designZS.getId());
|
||||
// userLikeZS.setDesignOutfitId(tDesignPythonOutfitZS.getId());
|
||||
// userLikeZSMapper.insert(userLikeZS);
|
||||
//
|
||||
// QueryWrapper<TDesignPythonOutfitDetail> designPythonOutfitDetailQueryWrapper = new QueryWrapper<>();
|
||||
// designPythonOutfitDetailQueryWrapper.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, tDesignPythonOutfit.getId());
|
||||
// List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(designPythonOutfitDetailQueryWrapper);
|
||||
// for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||
// com.ai.da.mapper.third.entity.TDesignPythonOutfitDetail tDesignPythonOutfitDetailZS = CopyUtil.copyObject(tDesignPythonOutfitDetail, com.ai.da.mapper.third.entity.TDesignPythonOutfitDetail.class);
|
||||
// tDesignPythonOutfitDetailZS.setDesignPythonOutfitId(tDesignPythonOutfitZS.getId());
|
||||
// tDesignPythonOutfitDetailZS.setId(null);
|
||||
// tDesignPythonOutfitDetailZS.setDesignId(designZS.getId());
|
||||
// designPythonOutfitDetailZSMapper.insert(tDesignPythonOutfitDetailZS);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
123
src/main/java/com/ai/da/common/task/PaymentTask.java
Normal file
123
src/main/java/com/ai/da/common/task/PaymentTask.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.common.enums.PayTypeEnum;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.service.*;
|
||||
import com.paypal.http.exceptions.SerializeException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PaymentTask {
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private StripeService stripeService;
|
||||
|
||||
@Resource
|
||||
private AffiliateService affiliateService;
|
||||
|
||||
// 考虑删除该定时任务(原因:之后的订单列允许用户查看发票,发票未过期时仍可以支付,所以不需要手动使订单过期)
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirmForStripe() throws SerializeException {
|
||||
|
||||
// 查看超过30分钟以上仍未支付的订单 置为超时订单
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(30, PayTypeEnum.STRIPE.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
stripeService.checkOrderStatus(orderNo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private PayPalCheckoutService payPalCheckoutService;
|
||||
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirmForPaypal() throws SerializeException {
|
||||
|
||||
// log.info("PayPal orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(30, PayTypeEnum.PAYPAL.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
payPalCheckoutService.checkOrderStatus(orderNo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private AliPayService aliPayService;
|
||||
|
||||
/**
|
||||
* 从第0秒开始每隔30秒执行1次,查询创建超过5分钟,并且未支付的订单
|
||||
*/
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirmForAlipay(){
|
||||
/*
|
||||
log.info("Alipay orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.ALIPAY.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
aliPayService.checkOrderStatus(orderNo);
|
||||
}*/
|
||||
}
|
||||
|
||||
// !!关闭此定时器,改为提前三天站内信提醒!!
|
||||
// 提前7天向用户发送提醒邮件,每天早上8点执行
|
||||
// @Scheduled(cron = "0 0 8 * * ?")
|
||||
public void subscriptionReminder(){
|
||||
stripeService.subscriptionReminder();
|
||||
}
|
||||
|
||||
|
||||
// 如果有订阅已创建,但是没有发邮件通知的,需要主动获取回调信息并向用户发送邮件
|
||||
public void checkSubscriptionPayment(){
|
||||
//
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
public void updateAffiliateInfoWithPayment(){
|
||||
// log.info("佣金计算定时器");
|
||||
affiliateService.updateAffiliateInfoWithPayment();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 8 28-31 * ?")
|
||||
public void commissionSummaryReminder(){
|
||||
// 每个月末的最后一天的早上八点执行
|
||||
LocalDate today = LocalDate.now();
|
||||
// 判断是否为月底
|
||||
if (today.plusDays(1).getDayOfMonth() == 1) {
|
||||
log.info("今天是月底,执行佣金结算提醒任务!");
|
||||
affiliateService.commissionCalculation(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
public void calcCouponsCommission(){
|
||||
// log.info("优惠券佣金计算定时器");
|
||||
affiliateService.calcCouponsCommission();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.common.enums.PayTypeEnum;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import com.ai.da.service.PayPalCheckoutService;
|
||||
import com.paypal.http.exceptions.SerializeException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PaypalTask {
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private PayPalCheckoutService payPalCheckoutService;
|
||||
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirm() throws SerializeException {
|
||||
|
||||
log.info("PayPal orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.PAYPAL.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
payPalCheckoutService.checkOrderStatus(orderNo);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,23 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import com.ai.da.model.dto.AlipayHKParametersDTO;
|
||||
import com.ai.da.model.dto.AlipayHKRequestDTO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
||||
import org.bouncycastle.crypto.digests.SHA256Digest;
|
||||
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
|
||||
import org.bouncycastle.crypto.signers.RSADigestSigner;
|
||||
import org.bouncycastle.crypto.util.PublicKeyFactory;
|
||||
import org.bouncycastle.openssl.PEMParser;
|
||||
import org.bouncycastle.util.io.pem.PemObject;
|
||||
import org.bouncycastle.util.io.pem.PemReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
@@ -25,22 +34,27 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AlipayHKEncryptionUtil {
|
||||
|
||||
@Value("${alipay.hk.merchant-id}")
|
||||
private static String merchantId;
|
||||
@Value("${alipayHK.merchantId}")
|
||||
private String merchantId;
|
||||
|
||||
@Value("${alipay.hk.segment-id}")
|
||||
private static String segmentId;
|
||||
@Value("${alipayHK.segmentId}")
|
||||
private String segmentId;
|
||||
|
||||
@Value("${alipay.hk.AESKey}")
|
||||
private static String aesKey;
|
||||
@Value("${alipayHK.AESKey}")
|
||||
private String aesKey;
|
||||
|
||||
@Value("${alipay.hk.rsaPrivateKey}")
|
||||
private static String privateKeyPath;
|
||||
@Value("${alipayHK.rsaPrivateKey}")
|
||||
private String privateKeyPath;
|
||||
|
||||
@Value("${alipayHK.rsaPublicKey}")
|
||||
private String publicKeyPath;
|
||||
|
||||
@Value("${alipayHK.CODPublicKey}")
|
||||
private String CODPublicKeyPath;
|
||||
|
||||
@Value("${alipay.hk.rsaPublicKey}")
|
||||
private static String publicKeyPath;
|
||||
|
||||
/**
|
||||
* 加密
|
||||
@@ -55,13 +69,14 @@ public class AlipayHKEncryptionUtil {
|
||||
* @throws BadPaddingException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
|
||||
public AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
|
||||
// Pre-shared secret key, DO NOT hardcode this key
|
||||
String key = aesKey;
|
||||
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
|
||||
// 使用私钥创建数字签名
|
||||
// Mode, aes-128-cbc for 128bit key
|
||||
String mode = "aes-128-cbc";
|
||||
// String mode = "aes-128-cbc";
|
||||
String mode = "aes-256-cbc";
|
||||
// Padding mode
|
||||
String padding = "pkcs7";
|
||||
// signature alogrithm
|
||||
@@ -75,18 +90,11 @@ public class AlipayHKEncryptionUtil {
|
||||
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
||||
// HashMap<String, Object> param = new HashMap<>();
|
||||
requestMessage.setParameters(param);
|
||||
/*String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
param.put("order_ref", orderRef);
|
||||
param.put("amount", 208.12);
|
||||
param.put("subject", "四月帳單 April Bill");
|
||||
param.put("wallet", "ALIPAYHK");
|
||||
param.put("segment_id", segmentId);
|
||||
param.put("payment_solution", "WAP");*/
|
||||
|
||||
|
||||
// Serialize message body
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
String content = gson.toJson(requestMessage);
|
||||
log.info("alipay-hk request 加密前:{}", content);
|
||||
|
||||
// Secure random iv 获取随机种子
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
@@ -144,7 +152,7 @@ public class AlipayHKEncryptionUtil {
|
||||
|
||||
// Encode to json
|
||||
String jsonEncoded = JSONObject.toJSONString(alipayHKRequestDTO);
|
||||
log.info(jsonEncoded);
|
||||
log.info("alipay-hk request 加密加签后:{}",jsonEncoded);
|
||||
|
||||
// String info = AlipayHKRequestUtil.createOrder(alipayHKRequestDTO);
|
||||
// log.info(info);
|
||||
@@ -159,7 +167,23 @@ public class AlipayHKEncryptionUtil {
|
||||
* @throws Exception
|
||||
*/
|
||||
private static PrivateKey readPrivateKeyFromFile(String filePath) throws Exception {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
||||
ClassPathResource classPathResource = new ClassPathResource(filePath);
|
||||
InputStream inputstream = classPathResource.getStream();
|
||||
String privateKeyContent = getString(inputstream);
|
||||
|
||||
// 进行 Base64 解码
|
||||
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
|
||||
|
||||
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getString(InputStream inputstream) throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
|
||||
// BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
||||
StringBuilder keyBuffer = new StringBuilder();
|
||||
String line;
|
||||
|
||||
@@ -174,20 +198,13 @@ public class AlipayHKEncryptionUtil {
|
||||
.replace("-----BEGIN PRIVATE KEY-----", "")
|
||||
.replace("-----END PRIVATE KEY-----", "")
|
||||
.replaceAll("\\s+", ""); // 去除空格、换行等字符
|
||||
|
||||
// 进行 Base64 解码
|
||||
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
|
||||
|
||||
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
return privateKeyContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 AES 密钥和随机向量进行解密
|
||||
*/
|
||||
public static String decryptAES(String encryptedText, String iv) throws Exception {
|
||||
public String decryptAES(String encryptedText, String iv) throws Exception {
|
||||
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText);
|
||||
byte[] ivBytes = Base64.getDecoder().decode(iv);
|
||||
|
||||
@@ -201,7 +218,7 @@ public class AlipayHKEncryptionUtil {
|
||||
return new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static void test() throws Exception {
|
||||
public void test() throws Exception {
|
||||
// 加密数据
|
||||
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
|
||||
requestMessage.setService("create_order");
|
||||
@@ -227,7 +244,7 @@ public class AlipayHKEncryptionUtil {
|
||||
|
||||
// 使用 RSA 公钥加密 AES 密钥
|
||||
String rsaPublicKeyPath = publicKeyPath;
|
||||
PublicKey publicKey = readPublicKey(new File(rsaPublicKeyPath));
|
||||
PublicKey publicKey = readPublicKey(rsaPublicKeyPath);
|
||||
|
||||
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
||||
// Cipher rsaCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
@@ -307,11 +324,14 @@ public class AlipayHKEncryptionUtil {
|
||||
System.out.println("数字签名验证结果:" + signatureValid);
|
||||
}
|
||||
|
||||
public static PublicKey readPublicKey(File file) throws Exception {
|
||||
// public static PublicKey readPublicKey(File file) throws Exception {
|
||||
public static PublicKey readPublicKey(String fileName) throws Exception {
|
||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
||||
|
||||
try (FileReader keyReader = new FileReader(file);
|
||||
PemReader pemReader = new PemReader(keyReader)) {
|
||||
ClassPathResource classPathResource = new ClassPathResource(fileName);
|
||||
InputStream inputStream = classPathResource.getStream();
|
||||
BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
try (PemReader pemReader = new PemReader(fileReader)) {
|
||||
|
||||
PemObject pemObject = pemReader.readPemObject();
|
||||
byte[] content = pemObject.getContent();
|
||||
@@ -326,4 +346,38 @@ public class AlipayHKEncryptionUtil {
|
||||
random.nextBytes(iv);
|
||||
return iv;
|
||||
}
|
||||
|
||||
public Boolean signatureVerification(String data, String signatureBase64){
|
||||
|
||||
Base64.Decoder decoder = Base64.getDecoder();
|
||||
// Verify key
|
||||
try {
|
||||
ClassPathResource classPathResource = new ClassPathResource(CODPublicKeyPath);
|
||||
InputStream inputstream = classPathResource.getStream();
|
||||
// 从指定的路径读取公钥文件
|
||||
InputStreamReader isrPub = new InputStreamReader(inputstream);
|
||||
PEMParser pemParserPub = new PEMParser(isrPub);
|
||||
// 使用 PEMParser 解析公钥文件
|
||||
SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject();
|
||||
// 从 SubjectPublicKeyInfo 创建 AsymmetricKeyParameter 对象
|
||||
AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo);
|
||||
// Verifying; 创建 RSADigestSigner 对象并使用 SHA-256 作为摘要算法
|
||||
RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest());
|
||||
// 初始化 RSADigestSigner,设置为验证模式并提供公钥参数
|
||||
verifier.init(false, pubKey);
|
||||
// 将要验证的数据转换为字节数组
|
||||
byte[] signMessageForVerifying = data.getBytes();
|
||||
// 将 Base64 编码的签名转换为字节数组
|
||||
byte[] signatureBase64ForVerifying = decoder.decode(signatureBase64);
|
||||
// 使用签名器更新要验证的数据
|
||||
verifier.update(signMessageForVerifying, 0, signMessageForVerifying.length);
|
||||
// 验证签名并返回结果
|
||||
Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifying);
|
||||
return verifyResult;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@ import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AlipayHKRequestUtil {
|
||||
|
||||
public static String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException {
|
||||
public String requestAlipayHK(AlipayHKRequestDTO alipayHKRequestDTO) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
@@ -27,27 +29,34 @@ public class AlipayHKRequestUtil {
|
||||
log.info("Alipay-HK send request unix timestamp: {}", epochMilli);
|
||||
|
||||
String jsonString = JSONObject.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue);
|
||||
log.info(jsonString);
|
||||
// log.info(jsonString);
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
// .url("https://aqs-api.sandbox-codpayment.com")
|
||||
.url("https://aqs-api.sandbox-codpayment.com/v1/service")
|
||||
// .url("https://aqs-api.sandbox-codpayment.com/v1/service")
|
||||
.url("https://aqs-api.codpayment.com/v1/service")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json;charset=utf-8")
|
||||
.build();
|
||||
Response response = null;
|
||||
Response response;
|
||||
String bodyString;
|
||||
try {
|
||||
// log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue));
|
||||
response = client.newCall(request).execute();
|
||||
assert response.body() != null;
|
||||
bodyString = response.body().string();
|
||||
} catch (Exception e) {
|
||||
// log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
// throw new BusinessException("generate.interface.error");
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
return response.body().string();
|
||||
JSONObject jsonObject = JSONObject.parseObject(bodyString);
|
||||
boolean success = (boolean) jsonObject.get("success");
|
||||
if (success){
|
||||
return bodyString;
|
||||
} else {
|
||||
String message = jsonObject.get("error_code").toString() + ":" + jsonObject.get("error");
|
||||
log.error("Alipay return message : {}", message);
|
||||
throw new BusinessException("Alipay return message : " + message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ComprehensivePunctuationConverter {
|
||||
private static final Map<Character, Character> FULL_TO_HALF_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
// 中文标点到英文标点的映射(扩展版)
|
||||
FULL_TO_HALF_MAP.put(',', ',');
|
||||
FULL_TO_HALF_MAP.put('。', '.');
|
||||
FULL_TO_HALF_MAP.put(';', ';');
|
||||
FULL_TO_HALF_MAP.put(':', ':');
|
||||
FULL_TO_HALF_MAP.put('?', '?');
|
||||
FULL_TO_HALF_MAP.put('!', '!');
|
||||
FULL_TO_HALF_MAP.put('(', '(');
|
||||
FULL_TO_HALF_MAP.put(')', ')');
|
||||
FULL_TO_HALF_MAP.put('【', '[');
|
||||
FULL_TO_HALF_MAP.put('】', ']');
|
||||
FULL_TO_HALF_MAP.put('「', '\'');
|
||||
FULL_TO_HALF_MAP.put('」', '\'');
|
||||
FULL_TO_HALF_MAP.put('『', '"');
|
||||
FULL_TO_HALF_MAP.put('』', '"');
|
||||
FULL_TO_HALF_MAP.put('、', '\\');
|
||||
FULL_TO_HALF_MAP.put('~', '~');
|
||||
FULL_TO_HALF_MAP.put('—', '-');
|
||||
FULL_TO_HALF_MAP.put('.', '.');
|
||||
FULL_TO_HALF_MAP.put('〈', '<');
|
||||
FULL_TO_HALF_MAP.put('〉', '>');
|
||||
FULL_TO_HALF_MAP.put('《', '«');
|
||||
FULL_TO_HALF_MAP.put('》', '»');
|
||||
FULL_TO_HALF_MAP.put('〝', '"');
|
||||
FULL_TO_HALF_MAP.put('〞', '"');
|
||||
FULL_TO_HALF_MAP.put('﹁', '"');
|
||||
FULL_TO_HALF_MAP.put('﹂', '"');
|
||||
FULL_TO_HALF_MAP.put('…', '.');
|
||||
FULL_TO_HALF_MAP.put('﹏', '_');
|
||||
|
||||
// 全角字母和数字
|
||||
for (char c = 'A'; c <= 'Z'; c++) {
|
||||
FULL_TO_HALF_MAP.put(c, (char)(c - 'A' + 'A'));
|
||||
}
|
||||
for (char c = 'a'; c <= 'z'; c++) {
|
||||
FULL_TO_HALF_MAP.put(c, (char)(c - 'a' + 'a'));
|
||||
}
|
||||
for (char c = '0'; c <= '9'; c++) {
|
||||
FULL_TO_HALF_MAP.put(c, (char)(c - '0' + '0'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串中的全角字符(包括标点、字母、数字)转换为半角字符
|
||||
*/
|
||||
public static String convertToHalfWidth(String input) {
|
||||
if (input == null || input.isEmpty()) {
|
||||
return input;
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
|
||||
// 检查映射表
|
||||
if (FULL_TO_HALF_MAP.containsKey(c)) {
|
||||
result.append(FULL_TO_HALF_MAP.get(c));
|
||||
}
|
||||
// 处理全角空格(Unicode 12288)
|
||||
else if (c == ' ') {
|
||||
result.append(' ');
|
||||
}
|
||||
// 其他字符保持不变
|
||||
else {
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String text = "这是一个全角示例,包含:中文标点、全角字母(ABC)、全角数字(123) 还有全角空格!";
|
||||
String text = "birds,yellow";
|
||||
String converted = convertToHalfWidth(text);
|
||||
System.out.println("原始文本: " + text);
|
||||
System.out.println("转换后: " + converted);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.text.ParseException;
|
||||
@@ -9,8 +10,8 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Slf4j
|
||||
@@ -18,6 +19,8 @@ public class DateUtil {
|
||||
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String YYYYMM = "yyyyMM";
|
||||
public static final String YYYY_MM_DD = "yyyyMMdd";
|
||||
public static final String YYYY_MM_DD_HH = "yyyyMMddHH";
|
||||
public static final String YYYY_MM_DD_hh_mm_ss = "yyyyMMddHHMMss";
|
||||
|
||||
/**
|
||||
* LocalDate -> Date
|
||||
@@ -81,4 +84,21 @@ public class DateUtil {
|
||||
return String.valueOf(epochSecond).substring(0, 10);
|
||||
}
|
||||
|
||||
public static String changeTimeStampFormat(Long timeStamp, String type, String format){
|
||||
// 将秒级时间戳转换为毫秒级
|
||||
if (type.equals("seconds")){
|
||||
timeStamp = timeStamp * 1000;
|
||||
}
|
||||
// 输出格式
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat(format, Locale.ENGLISH);
|
||||
// 创建Date对象
|
||||
Date date = new Date(timeStamp);
|
||||
// 格式化输出
|
||||
return outputFormat.format(date);
|
||||
}
|
||||
|
||||
public static String changeTimeStampFormat(LocalDateTime localDate){
|
||||
return localDate.format(DateTimeFormatter.ofPattern(CommonConstant.TIME_FORMAT_MMM_dd_yyyy_EEEE, Locale.US));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
53
src/main/java/com/ai/da/common/utils/ExcelReader.java
Normal file
53
src/main/java/com/ai/da/common/utils/ExcelReader.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ExcelReader {
|
||||
public static List<List<String>> readExcel(String filePath) throws IOException {
|
||||
List<List<String>> data = new ArrayList<>();
|
||||
try (FileInputStream fis = new FileInputStream(filePath);
|
||||
Workbook workbook = new XSSFWorkbook(fis)) {
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int numberOfColumns = sheet.getRow(0).getLastCellNum();
|
||||
|
||||
for (int i = 0; i < numberOfColumns; i++) {
|
||||
List<String> columnData = new ArrayList<>();
|
||||
for (Row row : sheet) {
|
||||
Cell cell = row.getCell(i);
|
||||
if (cell != null) {
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
columnData.add(cell.getStringCellValue());
|
||||
break;
|
||||
case NUMERIC:
|
||||
columnData.add(String.valueOf(cell.getNumericCellValue()));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
columnData.add(String.valueOf(cell.getBooleanCellValue()));
|
||||
break;
|
||||
default:
|
||||
// 跳过空单元格或其他类型(比如错误类型)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 只有当这一列有数据时,才添加到结果列表中
|
||||
if (!columnData.isEmpty()) {
|
||||
data.add(columnData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public final class LocalCacheUtils {
|
||||
private static LoadingCache<String, String> loadTokenCache() {
|
||||
LoadingCache<String, String> tokenCache = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(10)
|
||||
.expireAfterWrite(24 * 100, TimeUnit.HOURS)
|
||||
.expireAfterWrite(24 * (7 - 1), TimeUnit.HOURS)
|
||||
.initialCapacity(100)
|
||||
.maximumSize(10000)
|
||||
.recordStats()
|
||||
|
||||
@@ -8,16 +8,18 @@ import io.minio.http.Method;
|
||||
import io.minio.messages.DeleteError;
|
||||
import io.minio.messages.DeleteObject;
|
||||
import io.minio.messages.Item;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -25,6 +27,7 @@ import java.util.stream.Collectors;
|
||||
* @description: minio工具类
|
||||
* @version:3.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MinioUtil {
|
||||
@Autowired
|
||||
@@ -126,6 +129,26 @@ public class MinioUtil {
|
||||
return names;
|
||||
}
|
||||
|
||||
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
||||
String fileName = UUID.randomUUID().toString() + "." + imageType; // or any other image format
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(fileName)
|
||||
.stream(in, in.available(), -1)
|
||||
.contentType("image/png") // Set the content type according to your image format
|
||||
.build()
|
||||
);
|
||||
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* description: 上传文件
|
||||
*
|
||||
@@ -349,7 +372,7 @@ public class MinioUtil {
|
||||
* @param expiry 过期时间(单位:分)
|
||||
* @return 文件的临时URL,如果出现异常则返回null
|
||||
*/
|
||||
public String getPresignedUrl(String bucketName, String fileName, int expiry) {
|
||||
public String getPreSignedUrl(String bucketName, String fileName, int expiry) {
|
||||
try {
|
||||
return minioClient.getPresignedObjectUrl(
|
||||
GetPresignedObjectUrlArgs.builder()
|
||||
@@ -365,7 +388,7 @@ public class MinioUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public String getPresignedUrl(String path, int expiry) {
|
||||
public String getPreSignedUrl(String path, int expiry) {
|
||||
if (LocalCacheUtils.getPresignedUrlCache(path) != null) {
|
||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
||||
} else {
|
||||
@@ -375,12 +398,28 @@ public class MinioUtil {
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String fileName = path.substring(index + 1);
|
||||
String presignedUrl = getPresignedUrl(bucketName, fileName, expiry);
|
||||
String presignedUrl = getPreSignedUrl(bucketName, fileName, expiry);
|
||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
||||
return presignedUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPreSignedUrl(String path, int expiry, boolean resetCache) {
|
||||
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("The path is error!");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String fileName = path.substring(index + 1);
|
||||
String presignedUrl = getPreSignedUrl(bucketName, fileName, expiry);
|
||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
||||
return presignedUrl;
|
||||
} else {
|
||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将桶名、文件名从url中分离出来
|
||||
*
|
||||
@@ -398,7 +437,17 @@ public class MinioUtil {
|
||||
fileName.append("/");
|
||||
}
|
||||
}
|
||||
return getPresignedUrl(bucketName, String.valueOf(fileName), expiry);
|
||||
return getPreSignedUrl(bucketName, String.valueOf(fileName), expiry);
|
||||
}
|
||||
|
||||
public boolean doesObjectExist(String path) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("the.path.is.error");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String objectName = path.substring(index + 1);
|
||||
return doesObjectExist(bucketName, objectName);
|
||||
}
|
||||
|
||||
public boolean doesObjectExist(String bucketName, String objectName) {
|
||||
@@ -415,6 +464,112 @@ public class MinioUtil {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String base64UploadToPath(String base64, String bucketName, String path){
|
||||
String[] parts = base64.split(",");
|
||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
||||
String base64Data = parts[1];
|
||||
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
||||
String fileName;
|
||||
if (!StringUtil.isNullOrEmpty(path)){
|
||||
fileName = path + "." + imageType; // or any other image format
|
||||
}else {
|
||||
fileName = UUID.randomUUID() + "." + imageType;
|
||||
}
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(fileName)
|
||||
.stream(in, in.available(), -1)
|
||||
.contentType("image/" + imageType) // Set the content type according to your image format
|
||||
.build()
|
||||
);
|
||||
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 MinIO 下载对象到本地路径
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName MinIO 上对象的名称
|
||||
* @param localFilePath 本地文件路径
|
||||
*/
|
||||
public void downloadMinioObjectToLocal(String bucketName, String objectName, String localFilePath) {
|
||||
File localFile = new File(localFilePath);
|
||||
File parentDir = localFile.getParentFile();
|
||||
if (parentDir != null) {
|
||||
parentDir.mkdirs(); // 创建文件夹,确保路径结构与 MinIO 一致
|
||||
}
|
||||
|
||||
try (InputStream stream = minioClient.getObject(
|
||||
GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
FileOutputStream out = new FileOutputStream(localFile)) {
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = stream.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, bytesRead);
|
||||
}
|
||||
log.info("Downloaded object {} to {}", objectName, localFilePath);
|
||||
} catch (Exception e) {
|
||||
log.error("Error while downloading object {}: {}", objectName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从路径中提取存储桶名称
|
||||
*
|
||||
* @param path MinIO 路径
|
||||
* @return 存储桶名称
|
||||
*/
|
||||
public String getBucketNameFromPath(String path) {
|
||||
int index = path.indexOf("/");
|
||||
return path.substring(0, index); // 获取第一级路径作为 bucket 名称
|
||||
}
|
||||
|
||||
/**
|
||||
* 从路径中提取对象名称
|
||||
*
|
||||
* @param path MinIO 路径
|
||||
* @return 对象名称
|
||||
*/
|
||||
public String getObjectNameFromPath(String path) {
|
||||
int index = path.indexOf("/");
|
||||
return path.substring(index + 1); // 获取路径的其余部分作为对象名称
|
||||
}
|
||||
|
||||
public List<Integer> getImagesWidthAndHeight(String path){
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String objectName = path.substring(index + 1);
|
||||
try {
|
||||
// 从 MinIO 下载图片
|
||||
GetObjectResponse response = minioClient.getObject(
|
||||
GetObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.build()
|
||||
);
|
||||
|
||||
BufferedImage image = ImageIO.read(response);
|
||||
int width = image.getWidth();
|
||||
int height = image.getHeight();
|
||||
|
||||
log.info("Image path {}, Width: {}, Height: {}", path, width, height);
|
||||
response.close();
|
||||
return Arrays.asList(width, height);
|
||||
} catch (MinioException | IOException | NoSuchAlgorithmException | InvalidKeyException e) {
|
||||
log.error("图片:{}, 获取宽高异常", path);
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,4 +28,70 @@ public class PantoneUtils {
|
||||
return new int[]{Math.round(hsv[0]), Math.round(hsv[1] * 100), Math.round(hsv[2] * 100)};
|
||||
}
|
||||
|
||||
public static int[] hsvToRgb(int h, int s, int v) {
|
||||
// 确保 h 在 [0, 360) 范围内
|
||||
h = h % 360;
|
||||
if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
|
||||
// 确保 s 和 v 在 [0, 100] 范围内
|
||||
s = Math.max(0, Math.min(100, s));
|
||||
v = Math.max(0, Math.min(100, v));
|
||||
|
||||
// 将 s 和 v 映射到 [0, 1] 范围
|
||||
float sNorm = s / 100.0f;
|
||||
float vNorm = v / 100.0f;
|
||||
|
||||
// 计算色相所在的区间
|
||||
int hi = (h / 60) % 6;
|
||||
float f = (h / 60.0f) - hi;
|
||||
float p = vNorm * (1 - sNorm);
|
||||
float q = vNorm * (1 - f * sNorm);
|
||||
float t = vNorm * (1 - (1 - f) * sNorm);
|
||||
|
||||
float r, g, b;
|
||||
switch (hi) {
|
||||
case 0:
|
||||
r = vNorm;
|
||||
g = t;
|
||||
b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q;
|
||||
g = vNorm;
|
||||
b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p;
|
||||
g = vNorm;
|
||||
b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p;
|
||||
g = q;
|
||||
b = vNorm;
|
||||
break;
|
||||
case 4:
|
||||
r = t;
|
||||
g = p;
|
||||
b = vNorm;
|
||||
break;
|
||||
case 5:
|
||||
r = vNorm;
|
||||
g = p;
|
||||
b = q;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Invalid HSV values");
|
||||
}
|
||||
|
||||
// 将 RGB 值从 [0, 1] 转换为 [0, 255]
|
||||
int red = Math.round(r * 255);
|
||||
int green = Math.round(g * 255);
|
||||
int blue = Math.round(b * 255);
|
||||
|
||||
return new int[]{red, green, blue};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -84,8 +84,10 @@ public class RedisUtil {
|
||||
/**
|
||||
* 将数据放入set缓存
|
||||
*/
|
||||
public void addToSet(String key, String value) {
|
||||
public void addToSet(String key, String value, Long expiresIn) {
|
||||
redisTemplate.opsForSet().add(key, value);
|
||||
// 设置过期时间
|
||||
redisTemplate.expire(key, expiresIn, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +154,8 @@ public class RedisUtil {
|
||||
return redisTemplate.keys(key);
|
||||
}
|
||||
|
||||
public Long getSize(String key){return redisTemplate.opsForSet().size(key);}
|
||||
|
||||
public List<String> getMultiValue(Set<String> keys){
|
||||
return redisTemplate.opsForValue().multiGet(keys);
|
||||
}
|
||||
@@ -164,4 +168,141 @@ public class RedisUtil {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
public final static String PORTFOLIO_LIKE_KEY = "portfolio:like:";
|
||||
|
||||
public void likePost(Long portfolioId, Long userId) {
|
||||
redisTemplate.opsForSet().add(PORTFOLIO_LIKE_KEY + portfolioId, String.valueOf(userId));
|
||||
}
|
||||
|
||||
public Long getLikeCount(Long portfolioId) {
|
||||
String key = PORTFOLIO_LIKE_KEY + portfolioId;
|
||||
return redisTemplate.opsForSet().size(key);
|
||||
}
|
||||
|
||||
public List<Long> getLikedPortfolios(Long userId) {
|
||||
// 获取所有包含PORTFOLIO_LIKE_KEY的键
|
||||
Set<String> likedPortfolios = redisTemplate.keys(PORTFOLIO_LIKE_KEY + "*");
|
||||
|
||||
// 如果没有喜欢的,返回空列表
|
||||
if (likedPortfolios == null || likedPortfolios.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 过滤出包含指定用户ID的键,并提取投资组合ID
|
||||
return likedPortfolios.stream()
|
||||
.filter(key -> redisTemplate.opsForSet().isMember(key, String.valueOf(userId)))
|
||||
.map(key -> Long.valueOf(key.replace(PORTFOLIO_LIKE_KEY, "")))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void unLikePost(Long portfolioId, Long userId) {
|
||||
redisTemplate.opsForSet().remove(PORTFOLIO_LIKE_KEY + portfolioId, userId.toString());
|
||||
}
|
||||
|
||||
// 检查用户是否喜欢某个作品
|
||||
public boolean isPostLikedByUser(Long portfolioId, Long userId) {
|
||||
String key = PORTFOLIO_LIKE_KEY + portfolioId;
|
||||
Boolean isMember = redisTemplate.opsForSet().isMember(key, userId.toString());
|
||||
return isMember != null && isMember;
|
||||
}
|
||||
|
||||
public final static String PORTFOLIO_VIEW_KEY = "portfolio:view:";
|
||||
|
||||
public void increaseViewCount(Long portfolioId) {
|
||||
String key = PORTFOLIO_VIEW_KEY + portfolioId;
|
||||
redisTemplate.opsForValue().increment(key);
|
||||
}
|
||||
|
||||
public Long getViewCount(Long portfolioId) {
|
||||
String key = PORTFOLIO_VIEW_KEY + portfolioId;
|
||||
return redisTemplate.opsForValue().increment(key, 0);
|
||||
}
|
||||
|
||||
public Long getViewCount(String key) {
|
||||
Object value = redisTemplate.opsForValue().get(key);
|
||||
if (value instanceof Integer) {
|
||||
return Long.valueOf((Integer) value);
|
||||
} else if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
} else if (value instanceof String) {
|
||||
return Long.valueOf((String) value);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected value type");
|
||||
}
|
||||
}
|
||||
|
||||
public final static String PERSONAL_HOMEPAGE_VIEW_KEY = "PersonalHomepage:view:";
|
||||
|
||||
public void increasePersonalHomepageViewCount(Long accountId) {
|
||||
String key = PERSONAL_HOMEPAGE_VIEW_KEY + accountId;
|
||||
redisTemplate.opsForValue().increment(key);
|
||||
}
|
||||
|
||||
public Long getPersonalHomepageViewCount(Long accountId) {
|
||||
String key = PERSONAL_HOMEPAGE_VIEW_KEY + accountId;
|
||||
return redisTemplate.opsForValue().increment(key, 0);
|
||||
}
|
||||
|
||||
public final static String MOODBOARD_POSITION_KEY = "moodboard:position:";
|
||||
|
||||
public void saveMoodboardPosition(Long id, String moodboardPosition) {
|
||||
addToString(MOODBOARD_POSITION_KEY + id, moodboardPosition);
|
||||
}
|
||||
|
||||
public String getMoodboardPosition(Long id) {
|
||||
return getFromString(MOODBOARD_POSITION_KEY + id);
|
||||
}
|
||||
public final static String NICKNAME_MODIFY_TIMES = "NicknameModifyTimes:";
|
||||
public void increaseCount(String key) {
|
||||
redisTemplate.opsForValue().increment(key);
|
||||
}
|
||||
|
||||
public Long getIncrementCount(String key) {
|
||||
return redisTemplate.opsForValue().increment(key, 0);
|
||||
}
|
||||
|
||||
public void setKeyExpire(String key, Long expire) {
|
||||
redisTemplate.expire(key, expire, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
public final static String CHANGE_MAILBOX = "ChangeMailbox:";
|
||||
|
||||
// 每天允许通知3次
|
||||
public final static String UPLOAD_TIMEOUT_REMINDER_COUNTER = "UploadTimeoutReminderCounter";
|
||||
|
||||
public void addProcessId(String processId, int progress) {
|
||||
// Redis 中的键,可以通过 processId 来唯一标识
|
||||
String redisKey = "process:progress:" + processId;
|
||||
|
||||
// 将当前进度存储到 Redis
|
||||
redisTemplate.opsForValue().set(redisKey, String.valueOf(progress));
|
||||
|
||||
// 设置过期时间为 5 分钟(300 秒)
|
||||
redisTemplate.expire(redisKey, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public final static String PAYMENT_INFO_LAST_SCAN_TIME = "PaymentInfoLastScanTime";
|
||||
|
||||
public final static String AFFILIATE_LINK_VIEW_KEY = "AffiliateLink:view:";
|
||||
|
||||
public void increaseAffiliateLinkViewCount(Long accountId) {
|
||||
String key = AFFILIATE_LINK_VIEW_KEY + accountId;
|
||||
redisTemplate.opsForValue().increment(key);
|
||||
}
|
||||
|
||||
public Long getAffiliateLinkViewCount(Long accountId) {
|
||||
String key = AFFILIATE_LINK_VIEW_KEY + accountId;
|
||||
return redisTemplate.opsForValue().increment(key, 0);
|
||||
}
|
||||
|
||||
public void batchDeleteKeysWithSamePrefix(String prefix){
|
||||
Set<String> keys = redisTemplate.keys(prefix + "*");
|
||||
assert keys != null;
|
||||
if (!keys.isEmpty()){
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
public final static String STRIPE_EXCEPTION_LOG = "StripeException:";
|
||||
public final static String SUBSCRIPTION_SENT_EMAIL_TYPE = "SubscriptionEmailSentType:";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class RequestInfoUtil {
|
||||
|
||||
/**
|
||||
@@ -45,4 +54,58 @@ public class RequestInfoUtil {
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 免费 API 服务可能有请求频率限制,如果你需要处理大量 IP 地址,可能需要考虑使用付费服务或购买 IP 地理位置数据库。此外,始终要遵守 API 提供商的使用条款和隐私政策
|
||||
* @param ip https://ip-api.com/docs/api:json 使用的接口api
|
||||
* @return
|
||||
* {
|
||||
* "query": "24.48.0.1",
|
||||
* "status": "success",
|
||||
* "country": "Canada",
|
||||
* "countryCode": "CA",
|
||||
* "region": "QC",
|
||||
* "regionName": "Quebec",
|
||||
* "city": "Montreal",
|
||||
* "zip": "H1L",
|
||||
* "lat": 45.6026,
|
||||
* "lon": -73.5167,
|
||||
* "timezone": "America/Toronto",
|
||||
* "isp": "Le Groupe Videotron Ltee",
|
||||
* "org": "Videotron Ltee",
|
||||
* "as": "AS5769 Videotron Ltee"
|
||||
* }
|
||||
*/
|
||||
public static Map getIPLocation(String ip) {
|
||||
// String ip = "117.143.125.1"; // 替换为你想查询的 IP 地址
|
||||
// String ip = "194.5.48.180"; // 替换为你想查询的 IP 地址
|
||||
String apiURL = "http://ip-api.com/json/" + ip;
|
||||
|
||||
try {
|
||||
URL url = new URL(apiURL);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept", "application/json");
|
||||
|
||||
if (conn.getResponseCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
|
||||
}
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String output;
|
||||
StringBuilder outputBuilder = new StringBuilder();
|
||||
// System.out.println("Output from Server .... \n");
|
||||
while ((output = br.readLine()) != null) {
|
||||
outputBuilder.append(output);
|
||||
System.out.println(output);
|
||||
}
|
||||
conn.disconnect();
|
||||
Map map = JSONObject.parseObject(outputBuilder.toString(), Map.class);
|
||||
log.info("map: {}", map);
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
380
src/main/java/com/ai/da/common/utils/S3Util.java
Normal file
380
src/main/java/com/ai/da/common/utils/S3Util.java
Normal file
@@ -0,0 +1,380 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
|
||||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
|
||||
import software.amazon.awssdk.core.ResponseBytes;
|
||||
import software.amazon.awssdk.core.sync.RequestBody;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.s3.S3Client;
|
||||
import software.amazon.awssdk.services.s3.S3Configuration;
|
||||
import software.amazon.awssdk.services.s3.model.*;
|
||||
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
||||
import software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest;
|
||||
import software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.*;
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class S3Util {
|
||||
|
||||
@Value("${aws.s3.accessKeyId}")
|
||||
private String accessKeyId;
|
||||
|
||||
@Value("${aws.s3.secretKey}")
|
||||
private String secretKey;
|
||||
|
||||
@Value("${aws.s3.regionName}")
|
||||
private String region;
|
||||
|
||||
public static String S3_ACCESS_KEY_ID = null;
|
||||
|
||||
public static String S3_SECRET_KEY = null;
|
||||
|
||||
public static String S3_REGION = null;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
S3_ACCESS_KEY_ID = accessKeyId;
|
||||
S3_SECRET_KEY = secretKey;
|
||||
S3_REGION = region;
|
||||
}
|
||||
|
||||
private static S3Client s3Client;
|
||||
|
||||
private static S3Presigner s3Presigner;
|
||||
|
||||
/**
|
||||
* @return software.amazon.awssdk.services.s3.S3Client
|
||||
* @description: 获取S3客户端对象
|
||||
*/
|
||||
public synchronized S3Client getS3Client() {
|
||||
if (null == s3Client) {
|
||||
s3Client = S3Client.builder()
|
||||
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(S3_ACCESS_KEY_ID, S3_SECRET_KEY)))
|
||||
// .endpointOverride(URI.create(S3_URI))
|
||||
.serviceConfiguration(item -> item.pathStyleAccessEnabled(true).checksumValidationEnabled(false))
|
||||
.region(Region.of(S3_REGION))
|
||||
.build();
|
||||
}
|
||||
|
||||
return s3Client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return software.amazon.awssdk.services.s3.presigner.S3Presigner
|
||||
* @description: 获取预签名对象
|
||||
*/
|
||||
public synchronized S3Presigner getS3PreSigner() {
|
||||
if (null == s3Presigner) {
|
||||
s3Presigner = S3Presigner.builder()
|
||||
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(S3_ACCESS_KEY_ID, S3_SECRET_KEY)))
|
||||
// .endpointOverride(URI.create(S3_URI))
|
||||
.serviceConfiguration(S3Configuration.builder()
|
||||
.checksumValidationEnabled(false)
|
||||
.pathStyleAccessEnabled(true)
|
||||
.build())
|
||||
.region(Region.of(S3_REGION))
|
||||
.build();
|
||||
}
|
||||
return s3Presigner;
|
||||
}
|
||||
|
||||
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
|
||||
S3Client s3Client = getS3Client();
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
||||
String fileName = UUID.randomUUID() + "." + imageType; // or any other image format
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
||||
.bucket(bucketName)
|
||||
.contentType("image/png")
|
||||
.contentLength((long) in.available())
|
||||
.key(fileName)
|
||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
||||
.build();
|
||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(in, in.available()));
|
||||
|
||||
log.info("uploadImageFromBase64 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
public String upload(String bucketName, String path, MultipartFile file) {
|
||||
S3Client s3Client = getS3Client();
|
||||
try {
|
||||
String fileName = file.getOriginalFilename();
|
||||
assert fileName != null;
|
||||
String[] split = fileName.split("\\.");
|
||||
if (split.length > 1) {
|
||||
fileName = path + "/" + UUID.randomUUID() + "." + split[split.length - 1];
|
||||
} else {
|
||||
fileName = path + "/" + UUID.randomUUID();
|
||||
}
|
||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
||||
.bucket(bucketName)
|
||||
.contentType(file.getContentType())
|
||||
.contentLength(file.getSize())
|
||||
.key(fileName)
|
||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
||||
.build();
|
||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
|
||||
|
||||
log.info("upload 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件到S3失败 异常:{}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// todo
|
||||
public String upload(String bucketName, String path, MultipartFile file, String copy) {
|
||||
S3Client s3Client = getS3Client();
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = file.getInputStream();
|
||||
|
||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
||||
.bucket(bucketName)
|
||||
.contentType(file.getContentType())
|
||||
.contentLength(file.getSize())
|
||||
.key(path)
|
||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
||||
.build();
|
||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
|
||||
log.info("upload-copy 上传的位置:桶 - {},路径 - {}", bucketName, path);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return bucketName + "/" + path;
|
||||
}
|
||||
|
||||
public InputStream download(String path) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("the.path.is.error");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String objectName = path.substring(index + 1);
|
||||
return download(bucketName, objectName);
|
||||
}
|
||||
|
||||
public InputStream download(String bucketName, String objectName) {
|
||||
try {
|
||||
S3Client s3Client = getS3Client();
|
||||
GetObjectRequest objectRequest = GetObjectRequest
|
||||
.builder()
|
||||
.key(objectName)
|
||||
.bucket(bucketName)
|
||||
.build();
|
||||
|
||||
// ResponseBytes<GetObjectResponse> objectBytes = s3.getObjectAsBytes(objectRequest);
|
||||
ResponseBytes<GetObjectResponse> objectAsBytes = s3Client.getObjectAsBytes(objectRequest);
|
||||
byte[] data = objectAsBytes.asByteArray();
|
||||
log.info("download 下载图片位置:桶 - {},路径 - {}", bucketName, objectName);
|
||||
return new ByteArrayInputStream(data);
|
||||
|
||||
/*// Write the data to a local file.
|
||||
File myFile = new File("files/images.png");
|
||||
OutputStream os = new FileOutputStream(myFile);
|
||||
os.write(data);
|
||||
System.out.println("Successfully obtained bytes from an S3 object");
|
||||
os.close();
|
||||
return null;*/
|
||||
// return minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
} catch (Exception e) {
|
||||
log.error("");
|
||||
throw new BusinessException("");
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteObject(String path) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("The path is error!");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String objectName = path.substring(index + 1);
|
||||
deleteObject(bucketName, objectName);
|
||||
}
|
||||
|
||||
public void deleteObject(String bucketName, String objectName) {
|
||||
try {
|
||||
S3Client s3Client = getS3Client();
|
||||
DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest
|
||||
.builder()
|
||||
.key(objectName)
|
||||
.bucket(bucketName)
|
||||
.build();
|
||||
s3Client.deleteObject(deleteObjectRequest);
|
||||
log.info("Object " + objectName + " successfully removed from bucket " + bucketName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info("Error while removing object " + objectName + " from bucket " + bucketName + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String getPreSignedUrl(String path, int expiry) {
|
||||
if (LocalCacheUtils.getPresignedUrlCache(path) != null) {
|
||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
||||
} else {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("The path is error!");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String fileName = path.substring(index + 1);
|
||||
String preSignedUrl = getPreSignatureUrl(bucketName, fileName, expiry);
|
||||
LocalCacheUtils.setPresignedUrlCache(path, preSignedUrl);
|
||||
return preSignedUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPreSignedUrl(String path, int expiry, boolean resetCache) {
|
||||
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("The path is error!");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String fileName = path.substring(index + 1);
|
||||
String presignedUrl = getPreSignatureUrl(bucketName, fileName, expiry);
|
||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
||||
return presignedUrl;
|
||||
} else {
|
||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyName key名称: test/2022/06/123.pdf
|
||||
* @param signatureDurationTime 有效期 单位:秒
|
||||
* @return java.lang.String
|
||||
* @description: 生成预签名URL
|
||||
*/
|
||||
public String getPreSignatureUrl(String bucket, String keyName, Integer signatureDurationTime) {
|
||||
String preSignatureUrl = "";
|
||||
try {
|
||||
S3Presigner s3PreSigner = getS3PreSigner();
|
||||
S3Client s3Client = getS3Client();
|
||||
setObjectAcl(s3Client, bucket, keyName, ObjectCannedACL.PUBLIC_READ);
|
||||
|
||||
GetObjectRequest getObjectRequest = GetObjectRequest.builder()
|
||||
.bucket(bucket)
|
||||
.key(keyName)
|
||||
.build();
|
||||
|
||||
//设置预签名URL可访问时间
|
||||
signatureDurationTime = Optional.ofNullable(signatureDurationTime)
|
||||
.map(item -> {
|
||||
if (item.intValue() > CommonConstant.Numbers.NUMBER_10080) {
|
||||
item = CommonConstant.Numbers.NUMBER_10080;
|
||||
}
|
||||
return item;
|
||||
})
|
||||
.orElse(CommonConstant.Numbers.NUMBER_10);
|
||||
GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder()
|
||||
.signatureDuration(Duration.ofMinutes(signatureDurationTime))
|
||||
.getObjectRequest(getObjectRequest)
|
||||
.build();
|
||||
|
||||
PresignedGetObjectRequest presignedGetObjectRequest =
|
||||
s3PreSigner.presignGetObject(getObjectPresignRequest);
|
||||
|
||||
preSignatureUrl = String.valueOf(presignedGetObjectRequest.url());
|
||||
} catch (Exception e) {
|
||||
log.error("生成预签名URL失败,异常:{}", e.getMessage());
|
||||
}
|
||||
return preSignatureUrl;
|
||||
}
|
||||
|
||||
public static void setObjectAcl(S3Client s3, String bucketName, String keyName, ObjectCannedACL acl) {
|
||||
PutObjectAclRequest aclRequest = PutObjectAclRequest.builder()
|
||||
.bucket(bucketName)
|
||||
.key(keyName)
|
||||
.acl(acl)
|
||||
.build();
|
||||
s3.putObjectAcl(aclRequest);
|
||||
}
|
||||
public boolean doesObjectExist(String bucketName, String objectName) {
|
||||
try {
|
||||
S3Client s3Client = getS3Client();
|
||||
HeadObjectRequest headObjectRequest = HeadObjectRequest.builder()
|
||||
.bucket(bucketName)
|
||||
.key(objectName)
|
||||
.build();
|
||||
HeadObjectResponse headObjectResponse = s3Client.headObject(headObjectRequest);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.info("指定文件 {}/{} 不存在", bucketName, objectName);
|
||||
// 如果发生异常,说明文件不存在或者出现了其他错误
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String base64UploadToPath(String base64, String bucketName, String path) {
|
||||
S3Client s3Client = getS3Client();
|
||||
String[] parts = base64.split(",");
|
||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
||||
String base64Data = parts[1];
|
||||
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
||||
String fileName;
|
||||
if (!StringUtil.isNullOrEmpty(path)) {
|
||||
fileName = path + "." + imageType; // or any other image format
|
||||
} else {
|
||||
fileName = UUID.randomUUID() + "." + imageType;
|
||||
}
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
||||
.bucket(bucketName)
|
||||
.contentType("image/" + imageType)
|
||||
.contentLength((long) in.available())
|
||||
.key(fileName)
|
||||
.acl(ObjectCannedACL.PUBLIC_READ)
|
||||
.build();
|
||||
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(in, in.available()));
|
||||
|
||||
log.info("base64UploadToPath 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<String> listAllBucket() {
|
||||
S3Client s3Client = getS3Client();
|
||||
ListBucketsResponse listBucketsResponse = s3Client.listBuckets();
|
||||
List<Bucket> buckets = listBucketsResponse.buckets();
|
||||
return buckets.stream().map(Bucket::name).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,11 @@ package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.AffiliateEmailParamsDTO;
|
||||
import com.ai.da.model.dto.SubscriptionEmailParamsDTO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
@@ -53,10 +56,12 @@ public class SendEmailUtil {
|
||||
* 绑定邮箱
|
||||
*/
|
||||
public static String BIND_MAILBOX_SUBJECT = "绑定邮箱";
|
||||
public static String CHANGE_MAILBOX_SUBJECT = "Change Mailbox";
|
||||
/**
|
||||
* 登入模板id
|
||||
*/
|
||||
public static Long LOGIN_TEMPLATE_ID = 58020L;
|
||||
public static Long PORTFOLIO_REGISTER_ID = 124847L;
|
||||
/**
|
||||
* 修改密码模板id
|
||||
*/
|
||||
@@ -68,7 +73,10 @@ public class SendEmailUtil {
|
||||
/**
|
||||
* 绑定邮箱模板id
|
||||
*/
|
||||
public static Long BIND_MAILBOX_TEMPLATE_ID = 45619L;
|
||||
// public static Long BIND_MAILBOX_TEMPLATE_ID = 45619L;
|
||||
public static Long BIND_MAILBOX_TEMPLATE_ID = 132754L;
|
||||
|
||||
public static Long CHANGE_MAILBOX_TEMPLATE_ID = 128210L;
|
||||
|
||||
|
||||
public static Boolean send(String receiverAddress, String ip, Long templateId, String verifyCode) {
|
||||
@@ -91,7 +99,8 @@ public class SendEmailUtil {
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
String subject = templateId == LOGIN_TEMPLATE_ID ? LOGIN_SUBJECT :
|
||||
templateId == UPDATE_PWD_TEMPLATE_ID ? FORGET_PWD_SUBJECT :
|
||||
templateId == EXCEPTION_ID_TEMPLATE_ID ? EXCEPTION_ID_SUBJECT : BIND_MAILBOX_SUBJECT;
|
||||
templateId == EXCEPTION_ID_TEMPLATE_ID ? EXCEPTION_ID_SUBJECT :
|
||||
templateId == CHANGE_MAILBOX_TEMPLATE_ID ? CHANGE_MAILBOX_SUBJECT : BIND_MAILBOX_SUBJECT;
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(contractTemplate(templateId, verifyCode, ip));
|
||||
|
||||
@@ -134,7 +143,9 @@ public class SendEmailUtil {
|
||||
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
||||
private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L;
|
||||
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) {
|
||||
private final static Long NO_TRIAL_ORDER_LIST_ID = 122591L;
|
||||
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country, boolean link) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -168,10 +179,10 @@ public class SendEmailUtil {
|
||||
subject = "Approval Confirmation for AiDA System Trial Access";
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(NOTIFICATION_CHINESE_TEMPLATE_ID);
|
||||
}else {
|
||||
} else {
|
||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||
}
|
||||
template.setTemplateData(buildNotificationData(trialOrder));
|
||||
template.setTemplateData(buildNotificationData(trialOrder, link));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -218,7 +229,7 @@ public class SendEmailUtil {
|
||||
attachment.setFileName(fileName); // 设置附件文件名
|
||||
// 设置附件内容
|
||||
attachment.setContent(Base64.getEncoder().encodeToString(fileContent));
|
||||
req.setAttachments(new Attachment[] {attachment});
|
||||
req.setAttachments(new Attachment[]{attachment});
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
@@ -227,7 +238,43 @@ public class SendEmailUtil {
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void sendNoExcelEmail(String receiverAddress, String senderAddress) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
if (StringUtils.isEmpty(senderAddress)) {
|
||||
senderAddress = SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "昨日试用订单数据";
|
||||
template.setTemplateID(NO_TRIAL_ORDER_LIST_ID);
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
||||
|
||||
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
@@ -309,7 +356,7 @@ public class SendEmailUtil {
|
||||
}
|
||||
|
||||
// 构建试用订单通过通知数据
|
||||
private static String buildNotificationData(TrialOrder trialOrder) {
|
||||
private static String buildNotificationData(TrialOrder trialOrder, boolean link) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 设置试用订单通过通知相关数据
|
||||
jsonObject.put("title", trialOrder.getTitle());
|
||||
@@ -317,11 +364,20 @@ public class SendEmailUtil {
|
||||
jsonObject.put("givenName", trialOrder.getGivenName());
|
||||
jsonObject.put("userName", trialOrder.getUserName());
|
||||
jsonObject.put("email", trialOrder.getEmail());
|
||||
if (link) {
|
||||
jsonObject.put("days", 14);
|
||||
} else {
|
||||
jsonObject.put("days", 5);
|
||||
}
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
private final static Long UPGRADE_NOTIFICATION_ID = 118855L;
|
||||
public static void sendUpgradeNotification(Account account, String senderAddress) {
|
||||
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID = 118856L;
|
||||
private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L;
|
||||
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE = 122899L;
|
||||
|
||||
public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -340,8 +396,20 @@ public class SendEmailUtil {
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
|
||||
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
// if (type == 1) {
|
||||
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
// }else {
|
||||
// subject = "即将到来的AiDA 3.0系统升级";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
||||
// }
|
||||
if (type == 1) {
|
||||
subject = "Successful System Upgrade and New Features in AiDA 3.0";
|
||||
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
|
||||
}else {
|
||||
subject = "系统升级成功和AiDA 3.0新功能";
|
||||
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
|
||||
}
|
||||
template.setTemplateData(buildAccountData(account));
|
||||
|
||||
req.setSubject(subject);
|
||||
@@ -349,15 +417,18 @@ public class SendEmailUtil {
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info(senderAddress);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info(senderAddress);
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long GENERATE_EXCEPTION_WARNING_ID = 122589L;
|
||||
public static void sendGenerateExceptionWarning(String message){
|
||||
|
||||
public static void sendGenerateExceptionWarning(String message) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -394,7 +465,615 @@ public class SendEmailUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long QUESTIONNAIRE_FEEDBACK_EN_ID = 124151L;
|
||||
private final static Long QUESTIONNAIRE_FEEDBACK_CN_ID = 124156L;
|
||||
|
||||
public static void questionnaireRelatedNotify(String userName, String email, String language) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
|
||||
req.setDestination(new String[]{email});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
Template template = new Template();
|
||||
String subject = "Thank You for Completing the AiDA System Survey";
|
||||
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_EN_ID);
|
||||
if (language.equals("CN")) {
|
||||
subject = "感谢您完成AiDA系统问卷调查";
|
||||
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_CN_ID);
|
||||
}
|
||||
|
||||
JSONObject parameter = new JSONObject();
|
||||
parameter.put("userName", userName);
|
||||
|
||||
template.setTemplateData(parameter.toJSONString());
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 124889L;
|
||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 124888L;
|
||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 124892L;
|
||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 124891L;
|
||||
|
||||
public static void notificationForPaidUser(String receiverAddress, int emailType, String country, String userName, String date) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
JSONObject parameter = new JSONObject();
|
||||
switch (emailType) {
|
||||
// 新用户
|
||||
case 1:
|
||||
subject = "Welcome to AiDA!";
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_CN);
|
||||
} else {
|
||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
|
||||
}
|
||||
parameter.put("userName", userName);
|
||||
parameter.put("email", receiverAddress);
|
||||
break;
|
||||
// 续费用户
|
||||
case 2:
|
||||
subject = "Account renewal notification";
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_CN);
|
||||
} else {
|
||||
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_EN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
parameter.put("userName", userName);
|
||||
parameter.put("date", date);
|
||||
template.setTemplateData(parameter.toJSONString());
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Boolean designWorksRegister(String userEmail, String randomVerifyCode) {
|
||||
try {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
|
||||
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(new String[]{userEmail});
|
||||
String subject = "Tourist registration";
|
||||
req.setSubject(subject);
|
||||
|
||||
req.setTemplate(contractTemplate(PORTFOLIO_REGISTER_ID, randomVerifyCode, null));
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
// 输出json格式的字符串回包
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
return Boolean.TRUE;
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long NEW_USER_REGISTER_NOTIFICATION_EN = 126919L;
|
||||
|
||||
public static void notificationForRegisterUser(String receiverAddress) {
|
||||
try {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
req.setSubject("Welcome to AiDa");
|
||||
Template template = new Template();
|
||||
template.setTemplateID(NEW_USER_REGISTER_NOTIFICATION_EN);
|
||||
template.setTemplateData("{\"email\":\" " + receiverAddress + "\"}");
|
||||
req.setTemplate(template);
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送至{} 发送失败###{}", receiverAddress, e.toString());
|
||||
log.error(e.getMessage());
|
||||
// 这里不再抛出异常 失败就不发,保证后续正常运行
|
||||
// throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long CHANGE_MAILBOX_CONFIRM_CN = 128278L;
|
||||
private final static Long CHANGE_MAILBOX_CONFIRM_EN = 128277L;
|
||||
|
||||
public static void changeMailboxConfirm(String receiverAddress, String language, String name, String link) {
|
||||
try {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
Template template = new Template();
|
||||
if (language.equals("ENGLISH")) {
|
||||
req.setSubject("Change the email address bound to the AiDA account");
|
||||
template.setTemplateID(CHANGE_MAILBOX_CONFIRM_EN);
|
||||
} else {
|
||||
req.setSubject("更换AiDA账号绑定的邮箱地址");
|
||||
template.setTemplateID(CHANGE_MAILBOX_CONFIRM_CN);
|
||||
}
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("userName", name);
|
||||
param.put("link", link);
|
||||
|
||||
template.setTemplateData(param.toJSONString());
|
||||
req.setTemplate(template);
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long UPLOAD_TIMEOUT_REMINDER = 128324L;
|
||||
|
||||
public static void uploadTimeoutReminder(String userName, String time) {
|
||||
String xp = "xupei3360@163.com";
|
||||
String wxd = "X1627315083@163.com";
|
||||
String pkc = "kaicpang.pang@connect.polyu.hk";
|
||||
try {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(new String[]{xp, wxd, pkc});
|
||||
Template template = new Template();
|
||||
req.setSubject("上传图片超时提醒");
|
||||
template.setTemplateID(UPLOAD_TIMEOUT_REMINDER);
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("userName", userName);
|
||||
param.put("time", time);
|
||||
|
||||
template.setTemplateData(param.toJSONString());
|
||||
req.setTemplate(template);
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long HALFPRICEPROMOTION_CN_ID = 128582L;
|
||||
private final static Long HALFPRICEPROMOTION_EN_ID = 128583L;
|
||||
|
||||
public static void halfPricePromotion(Account account, String senderAddress, int type) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
if (StringUtils.isEmpty(senderAddress)) {
|
||||
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{account.getUserEmail()});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
// if (type == 1) {
|
||||
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
// }else {
|
||||
// subject = "即将到来的AiDA 3.0系统升级";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
||||
// }
|
||||
if (type == 1) {
|
||||
subject = "AiDA workshop - Win a trip to Hong Kong!";
|
||||
template.setTemplateID(HALFPRICEPROMOTION_EN_ID);
|
||||
} else {
|
||||
subject = "AiDA workshop - 赢取香港之旅";
|
||||
template.setTemplateID(HALFPRICEPROMOTION_CN_ID);
|
||||
}
|
||||
template.setTemplateData(buildAccountData(account));
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
private final static Long SYSTEM_UPGRADE_CN_ID = 131743L;
|
||||
private final static Long SYSTEM_UPGRADE_EN_ID = 131744L;
|
||||
public static void temporaryUpgrade(Account account, String senderAddress, int type) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
if (StringUtils.isEmpty(senderAddress)) {
|
||||
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{account.getUserEmail()});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
if (type == 1) {
|
||||
subject = "AiDA system upgrade completed";
|
||||
template.setTemplateID(SYSTEM_UPGRADE_EN_ID);
|
||||
}else {
|
||||
subject = "AiDA系统升级完成";
|
||||
template.setTemplateID(SYSTEM_UPGRADE_CN_ID);
|
||||
}
|
||||
template.setTemplateData(buildAccountData(account));
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long CANCEL_MERCHANT_EN = 130720L;
|
||||
// private final static Long NEW_MERCHANT_EN = 130721L;
|
||||
// private final static Long NEW_USER_EN = 130722L;
|
||||
// private final static Long NEW_USER_CN = 130723L;
|
||||
private final static Long NEW_MERCHANT_EN = 140335L;
|
||||
// private final static Long NEW_MERCHANT_EN = 135190L;
|
||||
// private final static Long NEW_USER_EN = 135189L;
|
||||
// private final static Long NEW_USER_CN = 135186L;
|
||||
private final static Long NEW_USER_EN = 140316L;
|
||||
private final static Long NEW_USER_CN = 140317L;
|
||||
private final static Long RENEWAL_MERCHANT_EN = 130724L;
|
||||
private final static Long RENEWAL_USER_EN = 130725L;
|
||||
private final static Long RENEWAL_USER_CN = 130726L;
|
||||
private final static Long RENEWAL_REMINDER_USER_EN = 130727L;
|
||||
private final static Long RENEWAL_REMINDER_USER_CN = 130728L;
|
||||
private final static Long PAYMENT_FAILED_NEW_MERCHANT_EN = 131230L;
|
||||
private final static Long PAYMENT_FAILED_RENEWAL_MERCHANT_EN = 131225L;
|
||||
private final static Long PAYMENT_FAILED_RENEWAL_USER_EN = 131563L;
|
||||
private final static Long PAYMENT_FAILED_RENEWAL_USER_CN = 131564L;
|
||||
|
||||
public static boolean subscriptionEmailReminder(String type, SubscriptionEmailParamsDTO subscriptionEmailParamsDTO, String language, String receiverAddress) {
|
||||
try {
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developer = "xupei3360@163.com";
|
||||
String[] receiverEmail = {merchantEmail, developer};
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest user = new SendEmailRequest();
|
||||
user.setFromEmailAddress(SEND_ADDRESS);
|
||||
user.setDestination(new String[]{receiverAddress});
|
||||
SendEmailRequest merchant = new SendEmailRequest();
|
||||
merchant.setFromEmailAddress(SEND_ADDRESS);
|
||||
merchant.setDestination(receiverEmail);
|
||||
Template templateUser = new Template();
|
||||
Template templateMerchant = new Template();
|
||||
switch (type) {
|
||||
case "cancel":
|
||||
merchant.setSubject("[Code-Create] Subscription Cancelled");
|
||||
templateMerchant.setTemplateID(CANCEL_MERCHANT_EN);
|
||||
break;
|
||||
case "fail_new":
|
||||
merchant.setSubject("[Code-Create] Payment Failed : New Order (" + subscriptionEmailParamsDTO.getOrderId() + ")");
|
||||
templateMerchant.setTemplateID(PAYMENT_FAILED_NEW_MERCHANT_EN);
|
||||
break;
|
||||
case "fail_renewal":
|
||||
merchant.setSubject("[Code-Create] Payment Failed : Renewal Order (" + subscriptionEmailParamsDTO.getOrderId() + ")");
|
||||
templateMerchant.setTemplateID(PAYMENT_FAILED_RENEWAL_MERCHANT_EN);
|
||||
// todo to user
|
||||
if (language.equals("ENGLISH")) {
|
||||
user.setSubject("[Code-Create] Payment Failed : Renewal Order (" + subscriptionEmailParamsDTO.getOrderId() + ")");
|
||||
templateUser.setTemplateID(PAYMENT_FAILED_RENEWAL_USER_EN);
|
||||
} else {
|
||||
user.setSubject("[Code-Create] 自动续费失败 (" + subscriptionEmailParamsDTO.getOrderId() + ")");
|
||||
templateUser.setTemplateID(PAYMENT_FAILED_RENEWAL_USER_CN);
|
||||
}
|
||||
break;
|
||||
case "new":
|
||||
merchant.setSubject("[Code-Create] New Order(" + subscriptionEmailParamsDTO.getOrderId() + ")");
|
||||
templateMerchant.setTemplateID(NEW_MERCHANT_EN);
|
||||
if (language.equals("ENGLISH")) {
|
||||
user.setSubject("[Code-Create] You have successfully subscribed to AiDA");
|
||||
templateUser.setTemplateID(NEW_USER_EN);
|
||||
} else {
|
||||
user.setSubject("[Code-Create] 您已成功订阅AiDA");
|
||||
templateUser.setTemplateID(NEW_USER_CN);
|
||||
}
|
||||
break;
|
||||
case "renewal":
|
||||
merchant.setSubject("[Code-Create] New subscription renewal order (" + subscriptionEmailParamsDTO.getOrderId() + ")");
|
||||
templateMerchant.setTemplateID(RENEWAL_MERCHANT_EN);
|
||||
if (language.equals("ENGLISH")) {
|
||||
user.setSubject("[Code-Create] AiDA Renewal Successful");
|
||||
templateUser.setTemplateID(RENEWAL_USER_EN);
|
||||
} else {
|
||||
user.setSubject("[Code-Create] AiDA续订成功");
|
||||
templateUser.setTemplateID(RENEWAL_USER_CN);
|
||||
}
|
||||
break;
|
||||
case "reminder":
|
||||
if (language.equals("ENGLISH")) {
|
||||
user.setSubject("[Code-Create] AiDA Subscription Renewal Reminder");
|
||||
templateUser.setTemplateID(RENEWAL_REMINDER_USER_EN);
|
||||
} else {
|
||||
user.setSubject("[Code-Create] AiDA续订提醒");
|
||||
templateUser.setTemplateID(RENEWAL_REMINDER_USER_CN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("unknown subscription email type");
|
||||
return false;
|
||||
// throw new BusinessException("unknown subscription email type");
|
||||
}
|
||||
|
||||
templateUser.setTemplateData(JSON.toJSONString(subscriptionEmailParamsDTO));
|
||||
user.setTemplate(templateUser);
|
||||
|
||||
templateMerchant.setTemplateData(JSON.toJSONString(subscriptionEmailParamsDTO));
|
||||
merchant.setTemplate(templateMerchant);
|
||||
|
||||
if (!type.equals("cancel") && !type.equals("fail_new")) {
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse respUser = client.SendEmail(user);
|
||||
log.info("邮件主题:{},发送结果toUser###{}", user.getSubject(), SendEmailResponse.toJsonString(respUser));
|
||||
}
|
||||
if (!type.equals("reminder")) {
|
||||
SendEmailResponse respMerchant = client.SendEmail(merchant);
|
||||
log.info("邮件主题:{},发送结果toMerchant###{}", merchant.getSubject(), SendEmailResponse.toJsonString(respMerchant));
|
||||
}
|
||||
return true;
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
return false;
|
||||
// throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long NEW_REGISTRATION = 132123L;
|
||||
private final static Long AFFILIATE_ACCEPTED = 132124L;
|
||||
private final static Long AFFILIATE_REFUSED = 132125L;
|
||||
private final static Long AFFILIATE_MONTHLY_SUMMARY = 132126L;
|
||||
|
||||
public static void affiliateEmailReminder(String[] receiverAddress, AffiliateEmailParamsDTO paramsDTO, String type) {
|
||||
try {
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(receiverAddress);
|
||||
Template template = new Template();
|
||||
switch (type) {
|
||||
case "new":
|
||||
req.setSubject("New Affiliate Registration");
|
||||
template.setTemplateID(NEW_REGISTRATION);
|
||||
break;
|
||||
case "accepted":
|
||||
req.setSubject("Affiliate Application Accepted");
|
||||
template.setTemplateID(AFFILIATE_ACCEPTED);
|
||||
break;
|
||||
case "refused":
|
||||
req.setSubject("Affiliate Application Refused");
|
||||
template.setTemplateID(AFFILIATE_REFUSED);
|
||||
break;
|
||||
case "summary":
|
||||
req.setSubject("Your Monthly AffiliateWP Summary for AiDA");
|
||||
template.setTemplateID(AFFILIATE_MONTHLY_SUMMARY);
|
||||
break;
|
||||
}
|
||||
|
||||
template.setTemplateData(JSON.toJSONString(paramsDTO));
|
||||
req.setTemplate(template);
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long CREDITS_PURCHASE_MERCHANT = 133275L;
|
||||
|
||||
public static void creditsPurchaseReminder(String username, String quantity, String amount) {
|
||||
try {
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
String merchantEmail = "kimwong@code-create.com.hk";
|
||||
String developerEmail = "xupei@code-create.com.hk";
|
||||
req.setDestination(new String[]{merchantEmail, developerEmail});
|
||||
Template template = new Template();
|
||||
req.setSubject("New Credit Purchase Order");
|
||||
template.setTemplateID(CREDITS_PURCHASE_MERCHANT);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 设置试用订单相关数据
|
||||
jsonObject.put("username", username);
|
||||
jsonObject.put("quantity", quantity);
|
||||
jsonObject.put("totalFee", amount);
|
||||
|
||||
template.setTemplateData(JSON.toJSONString(jsonObject));
|
||||
req.setTemplate(template);
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long COMMON_EXCEPTION_REMINDER = 135279L;
|
||||
public static void commonExceptionReminder(String functionName, String[] destination) {
|
||||
try {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(SEND_ADDRESS);
|
||||
req.setDestination(destination);
|
||||
Template template = new Template();
|
||||
req.setSubject("AiDA发生异常,请及时处理");
|
||||
template.setTemplateID(COMMON_EXCEPTION_REMINDER);
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("function", functionName);
|
||||
|
||||
// 邮件内容 {{function}}处理异常,请及时查看
|
||||
template.setTemplateData(param.toJSONString());
|
||||
req.setTemplate(template);
|
||||
|
||||
// 返回的resp是一个SendEmailResponse的实例,与请求对象对应
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("邮件发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.ai.da.common.websocket;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@ServerEndpoint(value = "/notification/{id}")
|
||||
@Component
|
||||
@Slf4j
|
||||
public class NotificationConnection {
|
||||
|
||||
//连接超时
|
||||
public static final long MAX_TIME_OUT = 3 * 60 * 1000;
|
||||
|
||||
private Session session;
|
||||
private Long userId;
|
||||
// 这里用ConcurrentHashMap 因为他是一个线程安全的Map
|
||||
private static ConcurrentHashMap<Long, NotificationConnection> websockets = new ConcurrentHashMap<>();
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("id") String id) { // 接收到前端传来的用户ID
|
||||
this.session = session;
|
||||
this.userId = Long.valueOf(id);
|
||||
this.session.setMaxIdleTimeout(MAX_TIME_OUT);
|
||||
websockets.put(Long.parseLong(id), this); //将ID作为key,当前的对象作为Value
|
||||
log.info("【建立连接】 用户为:{}", this.session);
|
||||
log.info("【建立连接】 用户Id为:{}", id);
|
||||
log.info("【当前连接总数】 为:{}", websockets.size());
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(CloseReason reason) {
|
||||
log.info("【连接断开】 用户为:{}, sessionId: {}, 原因为{}", this.userId, this.session.getId(), reason);
|
||||
log.info("【当前连接总数】 为:{}", websockets.size());
|
||||
websockets.remove(this.userId); // 将当前的对象从集合中删除
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误时调用
|
||||
* @param throwable 异常
|
||||
*/
|
||||
@OnError
|
||||
public void onError(Throwable throwable) {
|
||||
log.info("【连接异常】 用户为:{} , sessionId: {}", this.userId, this.session.getId(), throwable);
|
||||
websockets.remove(this.userId); // 将当前的对象从集合中删除
|
||||
log.info("【当前连接总数】 为:{}", websockets.size());
|
||||
}
|
||||
|
||||
//收到了客户端消息执行的操作
|
||||
@OnMessage
|
||||
public void onMessage(@RequestParam String text){
|
||||
Map<String, String> textMap = JSONObject.parseObject(text, Map.class);
|
||||
log.info("收到了一条来自 {} 的消息:{}, sessionId:{}", this.userId, textMap.get("text"), this.session.getId());
|
||||
// return "已收到你的消息";
|
||||
if (textMap.get("text").equals("PING")){
|
||||
sendMsg(JSON.toJSONString("PONG"), this.userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMsg(String message, Long userId) {
|
||||
if (userId == null) { // 如果等于null则证明是群发
|
||||
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
||||
// 这个就是遍历这个集合的过程....
|
||||
for (Map.Entry<Long, NotificationConnection> entry : websockets.entrySet()) {
|
||||
// 获取每一个Entry实例
|
||||
// 获取每一个Value,而这个Value就是WebSocket的实例
|
||||
NotificationConnection webSocket = entry.getValue();
|
||||
// 接下来就是遍历群发
|
||||
log.info("广播消息 【给用户】 :{}发送消息【{}】", webSocket, message);
|
||||
try {
|
||||
webSocket.session.getBasicRemote().sendText(message); // 发送!!!!!!!!!
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to send message to session {}: {}", webSocket.session.getId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
} else { // 如果不是群发,则判断ID,其余步骤一致
|
||||
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
||||
// 这个就是遍历这个集合的过程....
|
||||
for (Map.Entry<Long, NotificationConnection> entry : websockets.entrySet()) {
|
||||
// 获取每一个Entry实例
|
||||
// 获取每一个Value,而这个Value就是WebSocket的实例
|
||||
NotificationConnection webSocket = entry.getValue();
|
||||
// 获取每一个Key,这个Key就是用户ID
|
||||
Long key = entry.getKey();
|
||||
// 判断用户ID与当前的Key相等
|
||||
if (userId.equals(key)) {
|
||||
log.info("私发消息 【给用户】 :{}发送消息【{}】", key, message); // 打印
|
||||
if (webSocket.session.isOpen()){
|
||||
// 避免因为网络问题或其他原因导致连接突然关闭而报错
|
||||
try {
|
||||
webSocket.session.getBasicRemote().sendText(message); // 则发送给当前的用户即可
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to send message to session {}: {}", webSocket.session.getId(), e.getMessage());
|
||||
// 这里可以选择移除关闭的 session
|
||||
websockets.remove(entry.getKey());
|
||||
}
|
||||
}else {
|
||||
log.info("连接已关闭,sessionId:{}, userId:{}", webSocket.session.getId(), key);
|
||||
websockets.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ai.da.common.websocket.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
/**
|
||||
* Configuration of WebSocket
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.AccountExtend;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.AccountLoginVO;
|
||||
import com.ai.da.model.vo.AccountPreLoginVO;
|
||||
import com.ai.da.model.vo.BindEmailVO;
|
||||
import com.ai.da.model.vo.PersonalHomepageVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -44,8 +51,8 @@ public class AccountController {
|
||||
|
||||
@ApiOperation(value = "绑定邮箱")
|
||||
@PostMapping("/bindEmail")
|
||||
public Response<Boolean> bindEmail(@Valid @RequestBody AccountBindEmailDTO accountBindEmailDTO) {
|
||||
return Response.success(accountService.bindEmail(accountBindEmailDTO));
|
||||
public Response<BindEmailVO> bindEmail(@Valid @RequestBody AccountBindEmailDTO accountBindEmailDTO, HttpServletRequest request) {
|
||||
return Response.success(accountService.bindEmail(accountBindEmailDTO, request));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "忘记密码")
|
||||
@@ -153,4 +160,192 @@ public class AccountController {
|
||||
accountService.upgradeNotification();
|
||||
return Response.success(true);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "广场用户注册")
|
||||
@PostMapping("/designWorksRegister")
|
||||
public Response<Boolean> designWorksRegister(@Valid @RequestBody AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
|
||||
return Response.success(accountService.designWorksRegister(accountDesignWorksRegisterDTO));
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "广场用户注册")
|
||||
@PostMapping("/designWorksRegisterCode")
|
||||
public Response<AccountLoginVO> designWorksRegisterCode(@Valid @RequestBody AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
|
||||
return Response.success(accountService.designWorksRegisterCode(accountDesignWorksRegisterDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 填写调查问卷
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "填写调查问卷")
|
||||
@PostMapping("/questionnaire")
|
||||
public Response<Boolean> questionnaire(@Valid @RequestBody String questionnaireInfo){
|
||||
return Response.success(accountService.collectQuestionnaires(questionnaireInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参与活动 获取福利
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "参与活动 获取福利")
|
||||
@GetMapping("/activity")
|
||||
public Response<String> getActivityBenefits(){
|
||||
return Response.success(accountService.getActivityBenefits());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将用户账号过期时间设置为过期当天的23:59:59")
|
||||
@GetMapping("/setUserValidToDayEnd")
|
||||
public Response<List<Long>> setUserValidToDayEnd(){
|
||||
return Response.success(accountService.setUserValidToDayEnd());
|
||||
}
|
||||
|
||||
// 用户上传头像
|
||||
@ApiOperation(value = "上传头像")
|
||||
@PostMapping(path = "/uploadAvatar")
|
||||
public Response<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
|
||||
if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) {
|
||||
throw new BusinessException("file.cannot.be.empty");
|
||||
}
|
||||
return Response.success(accountService.uploadAvatar(file));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "个人主页浏览量增加")
|
||||
@GetMapping("/viewsIncrease")
|
||||
public Response<Boolean> viewsGet(@RequestParam("id") Long id) {
|
||||
return Response.success(accountService.viewsIncrease(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取个人主页信息")
|
||||
@GetMapping("/personalHomepage")
|
||||
public Response<PersonalHomepageVO> getPersonalHomepage(@RequestParam("id") Long id){
|
||||
return Response.success(accountService.getPersonalHomepage(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "getUsernameModifyTimes")
|
||||
@GetMapping("/getNicknameModifyTimes")
|
||||
public Response<Long> getNicknameModifyTimes(){
|
||||
return Response.success(accountService.getNicknameModifyTimes());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "editUserName")
|
||||
@GetMapping("/editUserName")
|
||||
public Response<String> editUserName(@RequestParam("newUserName") String newUserName){
|
||||
accountService.editUserName(newUserName);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
/*@ApiOperation(value = "verifyUserEmail")
|
||||
@GetMapping("/verifyUserEmail")
|
||||
public Response<String> verifyUserEmail(@RequestParam("verifyCode") String verifyCode){
|
||||
accountService.verifyUserEmail(verifyCode);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "changeUserEmail")
|
||||
@GetMapping("/changeUserEmail")
|
||||
public Response<String> changeUserEmail(@RequestParam("newMailbox") String newMailbox){
|
||||
accountService.changeUserEmail(newMailbox);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "activateNewEmail")
|
||||
@GetMapping("/activateNewEmail")
|
||||
public Response<String> activateNewEmail(@RequestParam("token") String token){
|
||||
accountService.activateNewEmail(token);
|
||||
return Response.success("success");
|
||||
}*/
|
||||
|
||||
@PostMapping("halfPricePromotion")
|
||||
@ApiOperation(value = "十月半价活动")
|
||||
public Response<Boolean> halfPricePromotion() {
|
||||
accountService.halfPricePromotion();
|
||||
return Response.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("temporaryUpgrade")
|
||||
@ApiOperation(value = "临时升级")
|
||||
public Response<Boolean> temporaryUpgrade() {
|
||||
accountService.temporaryUpgrade();
|
||||
return Response.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("enterpriseLogin")
|
||||
@ApiOperation(value = "企业登录")
|
||||
public Response<AccountLoginVO> enterpriseLogin(@Valid @RequestBody AccountLoginDTO accountDTO) {
|
||||
return Response.success(accountService.enterpriseLogin(accountDTO));
|
||||
}
|
||||
|
||||
@PostMapping("schoolLogin")
|
||||
@ApiOperation(value = "学校登录")
|
||||
public Response<AccountLoginVO> schoolLogin(@Valid @RequestBody AccountLoginDTO accountDTO) {
|
||||
return Response.success(accountService.schoolLogin(accountDTO));
|
||||
}
|
||||
|
||||
@PostMapping("addOrUpdateSubAccount")
|
||||
@ApiOperation(value = "子账号新增")
|
||||
public Response<Boolean> addSubAccount(@Valid @RequestBody AddSubAccountDTO addSubAccountDTO) {
|
||||
return Response.success(accountService.addSubAccount(addSubAccountDTO));
|
||||
}
|
||||
|
||||
@PostMapping("deleteSubAccount")
|
||||
@ApiOperation(value = "子账号删除")
|
||||
public Response<Boolean> deleteSubAccount(@Valid @RequestBody AddSubAccountDTO addSubAccountDTO) {
|
||||
return Response.success(accountService.deleteSubAccount(addSubAccountDTO));
|
||||
}
|
||||
|
||||
@PostMapping("subAccountList")
|
||||
@ApiOperation(value = "子账号查询")
|
||||
public Response<PageBaseResponse<Account>> subAccountList(@Valid @RequestBody SubAccountPageDTO subAccountPageDTO) {
|
||||
return Response.success(accountService.subAccountList(subAccountPageDTO));
|
||||
}
|
||||
|
||||
@GetMapping("accountDetail")
|
||||
@ApiOperation(value = "账号详情")
|
||||
public Response<Account> accountDetail(@RequestParam("id") Long id) {
|
||||
return Response.success(accountService.accountDetail(id));
|
||||
}
|
||||
|
||||
@PostMapping("getAccountDetail")
|
||||
@ApiOperation(value = "获取账户信息")
|
||||
public Response<AccountLoginVO> getAccountDetail() {
|
||||
return Response.success(accountService.getAccountDetail());
|
||||
}
|
||||
|
||||
@GetMapping("/bindGoogle")
|
||||
@ApiOperation(value = "绑定谷歌")
|
||||
public Response<AccountExtend> bindGoogle(@RequestParam("credential") String credential) {
|
||||
return Response.success(accountService.bindGoogle(credential));
|
||||
}
|
||||
|
||||
@GetMapping("/bindWeChat")
|
||||
@ApiOperation(value = "绑定微信")
|
||||
public Response<AccountExtend> bindWeChat(@RequestParam("code") String code) {
|
||||
return Response.success(accountService.bindWeChat(code));
|
||||
}
|
||||
|
||||
@GetMapping("/bindEmail")
|
||||
@ApiOperation(value = "绑定邮箱")
|
||||
public Response<BindEmailVO> bindEmail(@RequestParam("email") String email) {
|
||||
return Response.success(accountService.bindEmail(email));
|
||||
}
|
||||
|
||||
@GetMapping("/unbindWeChat")
|
||||
@ApiOperation(value = "解除绑定微信")
|
||||
public Response<Boolean> unbindWeChat() {
|
||||
return Response.success(accountService.unbindWeChat());
|
||||
}
|
||||
|
||||
@GetMapping("/unbindGoogle")
|
||||
@ApiOperation(value = "解除绑定谷歌")
|
||||
public Response<Boolean> unbindGoogle() {
|
||||
return Response.success(accountService.unbindGoogle());
|
||||
}
|
||||
|
||||
@PostMapping("/updateUserInfo")
|
||||
@ApiOperation(value = "更新用户国家、职业信息")
|
||||
public Response<Boolean> updateUserInfo(@Valid @RequestBody UpdateUserInfoDTO updateUserInfoDTO) {
|
||||
return Response.success(accountService.updateUserInfo(updateUserInfoDTO));
|
||||
}
|
||||
}
|
||||
|
||||
94
src/main/java/com/ai/da/controller/AffiliateController.java
Normal file
94
src/main/java/com/ai/da/controller/AffiliateController.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.AffiliateQueryDTO;
|
||||
import com.ai.da.model.vo.AffiliateInvitationDetailsVO;
|
||||
import com.ai.da.model.vo.AffiliateVO;
|
||||
import com.ai.da.service.AffiliateService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/affiliate")
|
||||
@Api(tags = "Affiliate模块")
|
||||
public class AffiliateController {
|
||||
|
||||
@Resource
|
||||
private AffiliateService affiliateService;
|
||||
|
||||
@ApiOperation(value = "注册成为affiliate")
|
||||
@GetMapping("/registration")
|
||||
public Response<Boolean> completeGuidance(@RequestParam(value = "promotionMethod", required = false) String promotionMethod) {
|
||||
return Response.success(affiliateService.registerAsAnAffiliate(promotionMethod));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取affiliate列表")
|
||||
@PostMapping("/list")
|
||||
public Response<PageBaseResponse<AffiliateVO>> getAffiliateList(@Valid @RequestBody AffiliateQueryDTO affiliateQueryDTO) {
|
||||
return Response.success(affiliateService.getAffiliateList(affiliateQueryDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取affiliate个人中心")
|
||||
@GetMapping("/personalCenter")
|
||||
public Response<AffiliateVO> personalAffiliateCenter() {
|
||||
return Response.success(affiliateService.personalAffiliateCenter());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取个人佣金图表数据")
|
||||
@GetMapping("/getPersonalMonthlyIncome")
|
||||
public Response<double[]> getPersonalMonthlyIncome(@RequestParam("year")int year) {
|
||||
return Response.success(affiliateService.getPersonalMonthlyIncome(year));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "审批affiliate申请")
|
||||
@GetMapping("/approval")
|
||||
public Response<Boolean> applicationApproval(@RequestParam("id") Long id,
|
||||
@RequestParam("isApproved")Boolean isApproved,
|
||||
@RequestParam("commission") Float commission) {
|
||||
return Response.success(affiliateService.applicationApproval(id, isApproved, commission));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新佣金比例")
|
||||
@GetMapping("/updateCommission")
|
||||
public Response<String> updateCommissionPercentage(@RequestParam("id") Long id, @RequestParam("commission") Float commission) {
|
||||
affiliateService.updateCommissionPercentage(id, commission);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
/*@ApiOperation(value = "定时计算佣金")
|
||||
@GetMapping("/testTask")
|
||||
public Response<String> testTask() {
|
||||
affiliateService.updateAffiliateInfoWithPayment();
|
||||
return Response.success("success ");
|
||||
}*/
|
||||
|
||||
/*@ApiOperation(value = "每月发送结算邮件")
|
||||
@GetMapping("/commissionCalculation")
|
||||
public Response<String> commissionCalculation(@RequestParam("year") Integer year, @RequestParam("month") Integer month) {
|
||||
affiliateService.commissionCalculation(year, month);
|
||||
return Response.success("success ");
|
||||
}*/
|
||||
|
||||
@ApiOperation(value = "affiliate链接浏览量增加")
|
||||
@GetMapping("/viewsIncrease")
|
||||
public Response<Boolean> viewsGet(@RequestParam("id") Long id) {
|
||||
return Response.success(affiliateService.affiliateLinkViewsIncrease(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取每个affiliate产生的收入")
|
||||
@PostMapping("/getEachAffiliateGeneratedRevenue")
|
||||
public Response<IPage<AffiliateInvitationDetailsVO>> getEachAffiliateGeneratedRevenue(@RequestBody AffiliateQueryDTO affiliateQueryDTO) {
|
||||
return Response.success(affiliateService.getEachAffiliateGeneratedRevenue(affiliateQueryDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.ProductPurchaseDTO;
|
||||
import com.ai.da.service.AliPayService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -8,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
@CrossOrigin
|
||||
@@ -21,12 +24,12 @@ public class AliPayController {
|
||||
private AliPayService aliPayService;
|
||||
|
||||
@ApiOperation("统一收单下单并支付页面接口的调用")
|
||||
@PostMapping("/trade/page/pay/{amount}")
|
||||
public Response<String> tradePagePay(@PathVariable Integer amount, @RequestParam String returnUrl){
|
||||
@PostMapping("/trade/page/pay")
|
||||
public Response<String> tradePagePay(@Valid @RequestBody ProductPurchaseDTO productPurchaseDTO, HttpServletRequest request){
|
||||
log.info("统一收单下单并支付页面接口的调用");
|
||||
//支付宝开放平台接受 request 请求对象后
|
||||
// 会为开发者生成一个html 形式的 form表单,包含自动提交的脚本
|
||||
String formStr = aliPayService.tradeCreate(amount, returnUrl);
|
||||
String formStr = aliPayService.tradeCreate(productPurchaseDTO, request);
|
||||
//我们将form表单字符串返回给前端程序,之后前端将会调用自动提交脚本,进行表单的提交
|
||||
//此时,表单会自动提交到action属性所指向的支付宝开放平台中,从而为用户展示一个支付页面
|
||||
return Response.success(formStr);
|
||||
|
||||
@@ -1,22 +1,48 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.ProductPurchaseDTO;
|
||||
import com.ai.da.service.AlipayHKService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/ali-pay-hk")
|
||||
@RequestMapping("/api/alipay-hk")
|
||||
@Api(tags = "网站支付 香港支付宝")
|
||||
@Slf4j
|
||||
public class AlipayHKController {
|
||||
|
||||
public Response<String> createOrder(){
|
||||
return Response.success();
|
||||
@Resource
|
||||
private AlipayHKService alipayHKService;
|
||||
|
||||
@ApiOperation(value = "创建订单")
|
||||
@PostMapping(value = "/createOrder")
|
||||
public Response<String> createOrder(@Valid @RequestBody ProductPurchaseDTO productPurchaseDTO, HttpServletRequest request) {
|
||||
String order = alipayHKService.createOrder(productPurchaseDTO, request);
|
||||
return Response.success(order);
|
||||
}
|
||||
|
||||
@ApiOperation("支付通知")
|
||||
@PostMapping("/trade/notify")
|
||||
public String callback(@RequestBody String paramString){
|
||||
log.info("alipay-hk callback parameter : {}", paramString);
|
||||
return alipayHKService.callback(paramString);
|
||||
}
|
||||
|
||||
@ApiOperation("订单查询")
|
||||
@PostMapping("/trade/query/{orderRef}")
|
||||
public Response<String> queryOrder(@PathVariable String orderRef){
|
||||
String s = alipayHKService.queryDetail(orderRef);
|
||||
return Response.success(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,62 +2,223 @@ package com.ai.da.controller;
|
||||
|
||||
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.DesignMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.AccountAddDTO;
|
||||
import com.ai.da.model.dto.QueryPaymentInfoDTO;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
import com.ai.da.model.vo.PaymentInfoVO;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.ai.da.model.vo.QueryUserConditionsVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import com.ai.da.service.ConvenientInquiryService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Api(tags = "便利查询")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/inquiry")
|
||||
public class ConvenientInquiryController {
|
||||
|
||||
@Resource
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
@Resource
|
||||
private DesignMapper designMapper;
|
||||
@Resource
|
||||
private ConvenientInquiryService convenientInquiryService;
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
|
||||
@ApiOperation("获取当前所有试用用户")
|
||||
@GetMapping("/getTrial")
|
||||
public Response<List<TrialOrder>> getTrial(){
|
||||
@PostMapping("/getTrial")
|
||||
public Response<IPage<TrialOrder>> getTrial(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
||||
List<TrialOrder> trialOrders = trialOrderMapper.selectList(null);
|
||||
return Response.success(trialOrders);
|
||||
}else {
|
||||
String userEmail = accountService.getById(accountId).getUserEmail();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|
||||
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|
||||
|| userEmail.equals("joho8228@hotmail.com")
|
||||
|| userEmail.equals("chelseayu@code-create.com.hk")
|
||||
|| userEmail.equals("cheungzt007@gmail.com")
|
||||
) {
|
||||
return Response.success(convenientInquiryService.getTrial(queryUserConditionsVO));
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取指定时间区间内所有用户design的使用情况")
|
||||
@GetMapping("/getDesignStatistic")
|
||||
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime,@RequestParam String endTime){
|
||||
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
|
||||
@RequestParam(required = false) List<Long> ids, @RequestParam(required = false) String email) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
||||
String userEmail = accountService.getById(accountId).getUserEmail();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|
||||
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|
||||
|| userEmail.equals("joho8228@hotmail.com")
|
||||
|| userEmail.equals("chelseayu@code-create.com.hk")
|
||||
|| userEmail.equals("cheungzt007@gmail.com")
|
||||
) {
|
||||
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
|
||||
if (StringUtil.isNullOrEmpty(endTime)){
|
||||
if (StringUtil.isNullOrEmpty(endTime)) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
Date date = new Date();
|
||||
endTime = simpleDateFormat.format(date);
|
||||
}
|
||||
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime);
|
||||
if (!StringUtil.isNullOrEmpty(email)){
|
||||
email = email.trim();
|
||||
}
|
||||
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime, ids, email);
|
||||
return Response.success(designStatistic);
|
||||
}else {
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//调查问卷
|
||||
@ApiOperation("获取调查问卷统计详情")
|
||||
@GetMapping("/getQuestionnaireStatistic")
|
||||
public Response<QuestionnaireFeedbackVO> getQuestionnaire() {
|
||||
return Response.success(convenientInquiryService.getQuestionnaireInfo());
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有调查问卷")
|
||||
@GetMapping("/getAllQuestionnaire")
|
||||
public Response<List<QuestionnaireVO>> getAllQuestionnaire() {
|
||||
return Response.success(convenientInquiryService.getAllQuestionnaire());
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期新用户")
|
||||
@PostMapping("/recentNewUser")
|
||||
public Response<IPage<Account>> recentNewUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
return Response.success(convenientInquiryService.recentNewUser(queryUserConditionsVO));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期新用户图表数据")
|
||||
@GetMapping("/recentNewUserChart")
|
||||
public Response<Map<String, Object>> recentNewUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userType") @RequestParam Integer userType) {
|
||||
return Response.success(convenientInquiryService.recentNewUserChart(startTime, endTime, userType));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期活跃用户")
|
||||
@PostMapping("/recentActiveUser")
|
||||
public Response<IPage<Account>> recentActiveUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
return Response.success(convenientInquiryService.recentActiveUser(queryUserConditionsVO));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期活跃用户图表数据")
|
||||
@GetMapping("/recentActiveUserChart")
|
||||
public Response<Integer> recentActiveUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime) {
|
||||
return Response.success(convenientInquiryService.recentActiveUserChart(startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户的各模块功能使用详情")
|
||||
@GetMapping("/getActiveUserFunc")
|
||||
public Response<Map<String, List<Object>>> getActiveUserFunc(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userIdList") @RequestParam @Nullable List<Long> userIdList) {
|
||||
return Response.success(convenientInquiryService.getActiveUserFunc(startTime, endTime, userIdList));
|
||||
}
|
||||
|
||||
@ApiOperation("试用用户到正式用户的转化率")
|
||||
@GetMapping("/conversionRate")
|
||||
public Response<Map<String, Object>> conversionRate(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
||||
return Response.success(convenientInquiryService.conversionRate(startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("试用用户国家/城市分布")
|
||||
@GetMapping("/trialUserCountry")
|
||||
public Response<Map<String, List<Object>>> trialUserCountry(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
||||
return Response.success(convenientInquiryService.trialUserCountry(startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("添加用户")
|
||||
@PostMapping("/addUser")
|
||||
public Response<Boolean> addUser(@Valid @RequestBody AccountAddDTO accountAddDTO) {
|
||||
Long userAccountId = UserContext.getUserHolder().getId();
|
||||
if (userAccountId.equals(31L) || userAccountId.equals(87L) || userAccountId.equals(83L)
|
||||
|| userAccountId.equals(6L) || userAccountId.equals(4L) || userAccountId.equals(73L)
|
||||
) {
|
||||
return Response.success(convenientInquiryService.addUser(accountAddDTO));
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户信息")
|
||||
@PostMapping("/modifyUser")
|
||||
public Response<Boolean> modifyUser(@ApiParam(value = "用户id") @RequestParam @Nullable Long accountId,
|
||||
@ApiParam(value = "有效期截止时间的毫秒级unix格式") @RequestParam @Nullable Long validEndTime,
|
||||
@ApiParam(value = "用户类型 1/2/3/0 -> yearly/monthly/trial/visitor") @RequestParam @Nullable Integer systemUser,
|
||||
@ApiParam("积分") @RequestParam @Nullable Long credits) {
|
||||
Long userAccountId = UserContext.getUserHolder().getId();
|
||||
if (userAccountId.equals(31L) || userAccountId.equals(87L) || userAccountId.equals(83L)
|
||||
|| userAccountId.equals(6L) || userAccountId.equals(4L) || userAccountId.equals(73L)
|
||||
) {
|
||||
return Response.success(convenientInquiryService.modifyUser(accountId, validEndTime, systemUser, credits));
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户信息")
|
||||
@PostMapping("/getUserInfo")
|
||||
public Response<IPage<Account>> getUserInfo(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
String userEmail = accountService.getById(accountId).getUserEmail();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|
||||
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|
||||
|| userEmail.equals("joho8228@hotmail.com")
|
||||
|| userEmail.equals("chelseayu@code-create.com.hk")
|
||||
|| userEmail.equals("cheungzt007@gmail.com")
|
||||
) {
|
||||
return Response.success(convenientInquiryService.getUserInfo(queryUserConditionsVO));
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有用户id")
|
||||
@GetMapping("/getAllUserId")
|
||||
public Response<List<Map<String, Object>>> getAllUsrIdList() {
|
||||
return Response.success(convenientInquiryService.getAllUserIdList());
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有交易信息")
|
||||
@PostMapping("/queryTransaction")
|
||||
public Response<PageBaseResponse<PaymentInfoVO>> queryTransactionRecords(@Valid @RequestBody QueryPaymentInfoDTO queryPaymentInfoDTO){
|
||||
return Response.success(convenientInquiryService.queryTransactionRecords(queryPaymentInfoDTO));
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有国家、城市")
|
||||
@GetMapping("/getCities")
|
||||
public Response<Map<String, List<String>>> getCities(){
|
||||
return Response.success(convenientInquiryService.getCities());
|
||||
}
|
||||
|
||||
@ApiOperation("下载交易记录")
|
||||
@PostMapping("/queryTransaction/download")
|
||||
public Response<String> exportTransactionRecords(@Valid @RequestBody QueryPaymentInfoDTO queryPaymentInfoDTO, HttpServletResponse response){
|
||||
return Response.success(convenientInquiryService.exportTransactionRecords(queryPaymentInfoDTO, response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DesignController {
|
||||
@ApiOperation(value = "设计 Conllection")
|
||||
@PostMapping("/designCollection")
|
||||
@CrossOrigin
|
||||
public Response<DesignCollectionVO> designCollection(@Valid @RequestBody DesignCollectionDTO designDTO) {
|
||||
public Response<String> designCollection(@Valid @RequestBody DesignCollectionDTO designDTO) {
|
||||
return Response.success(designService.designCollection(designDTO));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DesignController {
|
||||
|
||||
@ApiOperation(value = "重新设计 Collection")
|
||||
@PostMapping("/reDesignCollection")
|
||||
public Response<DesignCollectionVO> reDesignCollection(@Valid @RequestBody ReDesignCollectionDTO reDesignDTO) {
|
||||
public Response<String> reDesignCollection(@Valid @RequestBody ReDesignCollectionDTO reDesignDTO) {
|
||||
return Response.success(designService.reDesignCollection(reDesignDTO));
|
||||
}
|
||||
|
||||
@@ -71,10 +71,16 @@ public class DesignController {
|
||||
return Response.success(designService.dislike(disDesignLikeDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Design sort")
|
||||
@PostMapping("/sort")
|
||||
public Response<Boolean> sort(@Valid @RequestBody UserLikeSortDTO userLikeSortDTO) {
|
||||
return Response.success(designService.sort(userLikeSortDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "sketchBoard upload generate design前裁剪")
|
||||
@PostMapping("/sketchBoardsBoundingBox")
|
||||
public Response<List<CollectionSketchVO>> sketchesBoundingBox(@Valid @RequestBody SketchesBoundingBoxDTO sketchesBoundingBoxDTO) {
|
||||
return Response.success(designService.sketchesBoundingBox(sketchesBoundingBoxDTO));
|
||||
public Response<List<CollectionSketchVO>> sketchesBoundingBox(@Valid @RequestBody ReDesignCollectionDTO reDesignCollectionDTO) {
|
||||
return Response.success(designService.sketchesBoundingBox(reDesignCollectionDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过designItemId获取模特图")
|
||||
@@ -83,4 +89,16 @@ public class DesignController {
|
||||
return Response.success(designService.getModel(designItemIdList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取design结果")
|
||||
@GetMapping("/getDesignResult")
|
||||
public Response<DesignCollectionVO> getDesignResult(@RequestParam("requestId") String requestId, @RequestParam("objectSignList") List<String> objectSignList){
|
||||
return Response.success(designService.getDesignResult(requestId, objectSignList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "云生成")
|
||||
@PostMapping("/designCloud")
|
||||
@CrossOrigin
|
||||
public Response<String> designCloud(@Valid @RequestBody DesignCollectionDTO designDTO) {
|
||||
return Response.success(designService.designCloud(designDTO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,4 +77,18 @@ public class DesignDetailController {
|
||||
public Response<ComposeLayersVO> editPositionAndScale(@Valid @RequestBody EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException {
|
||||
return Response.success(designItemService.editLayersPositionAndScale(positionAndScaleVO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "mask数据兼容")
|
||||
@GetMapping("/convertWithoutGradient")
|
||||
public Response<String> convertHistoryMaskWithoutGradient(){
|
||||
designItemService.convertHistoryMaskWithoutGradient();
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "mask数据库路径更新")
|
||||
@GetMapping("/updateMaskUrl")
|
||||
public Response<String> updateMaskUrl(){
|
||||
designItemService.updateMaskUrl();
|
||||
return Response.success("success");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ public class ElementController {
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/** 该功能已删除 */
|
||||
@Deprecated
|
||||
@ApiOperation(value = "生成印花")
|
||||
@PostMapping("/generatePrint")
|
||||
public Response<GenerateCollectionItemVO> generatePrint(@Valid @RequestBody CollectionGeneratePrintDTO generatePrintDTO) {
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.GenerateLikeDTO;
|
||||
import com.ai.da.model.dto.GenerateModifyDTO;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
import com.ai.da.model.dto.ImageToSketchDTO;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.GenerateService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -27,11 +29,11 @@ public class GenerateController {
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
|
||||
@ApiOperation("自动识别sketch的caption 暂时未上")
|
||||
/*@ApiOperation("自动识别sketch的caption 暂时未上")
|
||||
@PostMapping("/caption")
|
||||
public Response<GenerateCaptionVO> generateCaption(@RequestParam Long sketchElementId) {
|
||||
return Response.success(generateService.generateCaption(sketchElementId));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*@ApiOperation("通过文字、图片生成图片")
|
||||
@PostMapping("/sketchAndPrint")
|
||||
@@ -63,8 +65,9 @@ public class GenerateController {
|
||||
@GetMapping("/stopWaiting")
|
||||
public Response<String> stopWaiting(@RequestParam("userId") Long userId,
|
||||
@RequestParam("uniqueId") List<String> uniqueId,
|
||||
@RequestParam("timeZone") String timeZone) {
|
||||
generateService.cancelGenerate(userId, uniqueId, timeZone);
|
||||
@RequestParam("timeZone") String timeZone,
|
||||
@RequestParam("type") String type) {
|
||||
generateService.cancelGenerate(userId, uniqueId, timeZone, type);
|
||||
return Response.success("stop waiting successfully");
|
||||
}
|
||||
|
||||
@@ -82,5 +85,17 @@ public class GenerateController {
|
||||
return Response.success(generateResult);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "imageToSketch")
|
||||
@PostMapping("/imageToSketch")
|
||||
public Response<GenerateResultVO> imageToSketch(@Valid @RequestBody ImageToSketchDTO imageToSketchDTO) {
|
||||
return Response.success(generateService.imageToSketch(imageToSketchDTO));
|
||||
}
|
||||
|
||||
// modifySketch
|
||||
@ApiOperation(value = "modifySketch")
|
||||
@PostMapping("/modifySketch")
|
||||
public Response<GenerateResultVO> modifySketch(@Valid @RequestBody GenerateModifyDTO generateModifyDTO) {
|
||||
return Response.success(generateService.modifySketch(generateModifyDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class LibraryController {
|
||||
Response<String> response = new Response();
|
||||
log.info("Models打点预览入参####{}", JSON.toJSONString(modelsDotDTO));
|
||||
String url = libraryModelPointService.modelsDot(modelsDotDTO);
|
||||
response.setData(minioUtil.getPresignedUrl(url, 24 * 60));
|
||||
response.setData(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.GetNotificationDTO;
|
||||
import com.ai.da.model.vo.NotificationVO;
|
||||
import com.ai.da.model.dto.PublishSysNotificationDTO;
|
||||
import com.ai.da.service.MessageCenterService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "消息中心模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/message")
|
||||
public class MessageCenterController {
|
||||
|
||||
@Resource
|
||||
private MessageCenterService messageCenterService;
|
||||
|
||||
// 获取未读消息总数
|
||||
@ApiOperation(value = "获取未读消息数")
|
||||
@GetMapping("/getUnreadCount")
|
||||
public Response<Map<String, Long>> getUnreadMessage(){
|
||||
return Response.success(messageCenterService.getAllTypeMessageUnreadCount());
|
||||
}
|
||||
|
||||
// 获取历史消息
|
||||
@ApiOperation(value = "获取历史消息")
|
||||
@PostMapping("/getHistoryNotification")
|
||||
public Response<PageBaseResponse<NotificationVO>> getHistoryNotification(@Valid @RequestBody GetNotificationDTO getNotificationDTO) {
|
||||
return Response.success(messageCenterService.getHistoryNotification(getNotificationDTO));
|
||||
}
|
||||
|
||||
// 已读消息
|
||||
@ApiOperation(value = "设置消息状态为已读")
|
||||
@PostMapping("/setReadStatus")
|
||||
public Response<Boolean> setReadStatus(@RequestParam("notificationIdList") List<Long> notificationIdList, @RequestParam("type") String type) {
|
||||
return Response.success(messageCenterService.setReadStatus(notificationIdList, type));
|
||||
}
|
||||
|
||||
// 发布系统消息
|
||||
@ApiOperation(value = "发布系统消息")
|
||||
@PostMapping("/publishSysMessage")
|
||||
public Response<String> publishSysMessage(@Valid @RequestBody PublishSysNotificationDTO message) {
|
||||
messageCenterService.publishSystemNotification(message);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "一键已读")
|
||||
@PostMapping("/oneClickRead")
|
||||
public Response<String> setReadAll(@RequestParam("type") String type) {
|
||||
messageCenterService.setReadAll(type);
|
||||
return Response.success("success");
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,10 @@ package com.ai.da.controller;
|
||||
import com.ai.da.common.enums.OrderStatusEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.model.dto.QueryPageByTimeDTO;
|
||||
import com.ai.da.model.vo.OrderListVO;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import com.ai.da.service.PaymentInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -22,10 +23,13 @@ public class OrderInfoController {
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private PaymentInfoService paymentInfoService;
|
||||
|
||||
@ApiOperation("订单列表")
|
||||
@PostMapping("/list")
|
||||
public Response<PageBaseResponse<OrderInfo>> list(@Valid @RequestBody QueryPageByTimeDTO queryPageByTimeDTO){
|
||||
PageBaseResponse<OrderInfo> orderByAccountId = orderInfoService.getOrderByPage(queryPageByTimeDTO);
|
||||
public Response<PageBaseResponse<OrderListVO>> list(@Valid @RequestBody QueryPageByTimeDTO queryPageByTimeDTO){
|
||||
PageBaseResponse<OrderListVO> orderByAccountId = paymentInfoService.getPaymentInfo(queryPageByTimeDTO);
|
||||
// List<OrderInfo> list = orderInfoService.listOrderByCreateTimeDesc();
|
||||
return Response.success(orderByAccountId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.ProductPurchaseDTO;
|
||||
import com.ai.da.service.PayPalCheckoutService;
|
||||
import com.paypal.http.HttpResponse;
|
||||
import com.paypal.http.exceptions.SerializeException;
|
||||
@@ -14,6 +15,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -26,9 +28,9 @@ public class PayPalCheckoutController {
|
||||
private PayPalCheckoutService payPalCheckoutService;
|
||||
|
||||
@ApiOperation(value = "创建订单")
|
||||
@PostMapping(value = "/trade/{amount}")
|
||||
public Response<HashMap<String, String>> createOrder(@PathVariable Integer amount, @RequestParam String returnUrl) throws SerializeException {
|
||||
HashMap<String, String> approvalUrl = payPalCheckoutService.createOrder(amount,returnUrl);
|
||||
@PostMapping(value = "/trade")
|
||||
public Response<HashMap<String, String>> createOrder(@Valid @RequestBody ProductPurchaseDTO productPurchaseDTO, HttpServletRequest request) throws SerializeException {
|
||||
HashMap<String, String> approvalUrl = payPalCheckoutService.createOrder(productPurchaseDTO, request);
|
||||
return Response.success(approvalUrl);
|
||||
}
|
||||
|
||||
|
||||
157
src/main/java/com/ai/da/controller/PortfolioController.java
Normal file
157
src/main/java/com/ai/da/controller/PortfolioController.java
Normal file
@@ -0,0 +1,157 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.model.vo.CommentVO;
|
||||
import com.ai.da.model.vo.PortfolioVO;
|
||||
import com.ai.da.model.vo.UserLikeChooseVO;
|
||||
import com.ai.da.service.PortfolioService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "Portfolio模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/portfolio")
|
||||
public class PortfolioController {
|
||||
|
||||
@Resource
|
||||
private PortfolioService portfolioService;
|
||||
|
||||
@ApiOperation(value = "发布作品集")
|
||||
@PostMapping("/publish")
|
||||
public Response<Long> preLogin(@RequestParam("file") MultipartFile canvas, @RequestParam("data") String data) {
|
||||
return Response.success(portfolioService.publish(canvas, data));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除作品集")
|
||||
@GetMapping("/delete")
|
||||
public Response<Boolean> delete(@RequestParam("id") Long id) {
|
||||
return Response.success(portfolioService.delete(id));
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "作品集page")
|
||||
@PostMapping("/page")
|
||||
public Response<PageBaseResponse<PortfolioVO>> page(@Valid @RequestBody QueryPortfolioPageDTO query) {
|
||||
return Response.success(portfolioService.page(query));
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "作品详情")
|
||||
@PostMapping("/detail")
|
||||
public Response<PortfolioVO> detail(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.detail(portfolioDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择作品")
|
||||
@PostMapping("/choose")
|
||||
public Response<UserLikeChooseVO> choose(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.choose(portfolioDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新作品")
|
||||
@PostMapping("/update")
|
||||
public Response<PortfolioVO> update(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.update(portfolioDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "广场用户注册")
|
||||
@PostMapping("/designWorksRegister")
|
||||
public Response<Boolean> designWorksRegister(@Valid @RequestBody DesignWorksRegisterDTO designWorksRegisterDTO) {
|
||||
return Response.success(portfolioService.designWorksRegister(designWorksRegisterDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "喜欢")
|
||||
@GetMapping("/like")
|
||||
public Response<Boolean> like(@RequestParam("id") Long id) {
|
||||
return Response.success(portfolioService.like(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不喜欢")
|
||||
@GetMapping("/unlike")
|
||||
public Response<Boolean> unlike(@RequestParam("id") Long id) {
|
||||
return Response.success(portfolioService.unlike(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取点赞数")
|
||||
@GetMapping("/getLikeCount")
|
||||
public Response<Long> getLikeCount(@RequestParam("id") Long id) {
|
||||
return Response.success(portfolioService.getLikeCount(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "评论")
|
||||
@PostMapping("/comment")
|
||||
public Response<Boolean> comment(@Valid @RequestBody CommentDTO commentDTO) {
|
||||
return Response.success(portfolioService.comment(commentDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "评论列表")
|
||||
@PostMapping("/commentPage")
|
||||
public Response<PageBaseResponse<CommentVO>> commentPage(@Valid @RequestBody CommentPageDTO commentPageDTO) {
|
||||
return Response.success(portfolioService.commentPage(commentPageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "增加浏览量")
|
||||
@GetMapping("/viewsIncrease")
|
||||
public Response<Boolean> viewsIncrease(@RequestParam("id") Long id) {
|
||||
return Response.success(portfolioService.viewsIncrease(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "浏览量获取")
|
||||
@GetMapping("/viewsGet")
|
||||
public Response<Long> viewsGet(@RequestParam("id") Long id) {
|
||||
return Response.success(portfolioService.viewsGet(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除评论")
|
||||
@PostMapping("/commentDelete")
|
||||
public Response<Boolean> commentDelete(@Valid @RequestBody CommentDTO commentDTO) {
|
||||
return Response.success(portfolioService.commentDelete(commentDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "关注")
|
||||
@GetMapping("/follow")
|
||||
public Response<String> follow(@RequestParam("followeeId") Long followeeId) {
|
||||
portfolioService.follow(followeeId);
|
||||
return Response.success(BusinessException.getMessageFromResource("subscription.success"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取消关注")
|
||||
@GetMapping("/cancelFollow")
|
||||
public Response<String> cancelFollow(@RequestParam("followeeId") Long followeeId) {
|
||||
portfolioService.cancelFollow(followeeId);
|
||||
return Response.success(BusinessException.getMessageFromResource("unsubscribe.success"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取关注列表")
|
||||
@PostMapping("/getFolloweeList")
|
||||
public Response<List<AccountFollowVO>> getFolloweeList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) {
|
||||
return Response.success(portfolioService.getFolloweeList(getFollowListDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取粉丝列表")
|
||||
@PostMapping("/getFollowerList")
|
||||
public Response<List<AccountFollowVO>> getFollowerList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) {
|
||||
return Response.success(portfolioService.getFollowerList(getFollowListDTO));
|
||||
}
|
||||
|
||||
|
||||
/* @ApiOperation(value = "按标签名查询作品")
|
||||
@GetMapping("/queryPortfolioByTag")
|
||||
public Response<List<PortfolioVO>> queryPortfolioByTag(@RequestParam(value = "tagName", required = false) String tagName,
|
||||
@RequestParam(value = "tagId", required = false) Long tagId) {
|
||||
return Response.success(portfolioService.queryPortfolioByTag(tagName, tagId));
|
||||
}*/
|
||||
}
|
||||
@@ -8,13 +8,11 @@ import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.primary.TDesignPythonOutfitMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.mapper.primary.entity.TDesignPythonOutfit;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -26,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
@@ -50,6 +49,8 @@ public class SavedCollectionController {
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
@Resource
|
||||
private PortfolioService portfolioService;
|
||||
|
||||
@ApiOperation(value = "History用户分页分组列表")
|
||||
@PostMapping("/queryUserGroup")
|
||||
@@ -103,9 +104,9 @@ public class SavedCollectionController {
|
||||
}
|
||||
List<Long> groupIds = page.getRecords().stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
||||
List<UserLikeVO> groupDetails = userLikeService.getGroupDetails(groupIds);
|
||||
if (CollectionUtils.isEmpty(groupDetails)) {
|
||||
throw new BusinessException("groupDetails.not.found");
|
||||
}
|
||||
// if (CollectionUtils.isEmpty(groupDetails)) {
|
||||
// throw new BusinessException("groupDetails.not.found");
|
||||
// }
|
||||
Map<Long, List<UserLikeVO>> groupDetailMap = groupDetails.stream()
|
||||
.collect(Collectors.groupingBy(UserLikeVO::getUserLikeGroupId));
|
||||
|
||||
@@ -116,13 +117,25 @@ public class SavedCollectionController {
|
||||
userLikeGroupVO.setUpdateDate(group.getUpdateDate().getTime());
|
||||
userLikeGroupVO.setAuthor(account.getUserName());
|
||||
//count 和detail
|
||||
List<UserLikeVO> details = groupDetailMap.get(group.getId());
|
||||
for (UserLikeVO detail : details) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(detail.getDesignOutfitId());
|
||||
detail.setUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
if (groupDetailMap.keySet().contains(group.getId())) {
|
||||
List<UserLikeVO> details = groupDetailMap.get(group.getId());
|
||||
for (UserLikeVO detail : details) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(detail.getDesignOutfitId());
|
||||
detail.setUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
}
|
||||
userLikeGroupVO.setGroupDetails(details);
|
||||
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size());
|
||||
}else {
|
||||
userLikeGroupVO.setSketchCount(0);
|
||||
}
|
||||
if (userLikeGroupVO.getOriginal() == 0) {
|
||||
userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName());
|
||||
Portfolio byId = portfolioService.getByIdAll(userLikeGroupVO.getOriginalPortfolioId());
|
||||
if (Objects.nonNull(byId)) {
|
||||
String portfolioName = byId.getPortfolioName();
|
||||
userLikeGroupVO.setOriginalPortfolioName(portfolioName);
|
||||
}
|
||||
}
|
||||
userLikeGroupVO.setGroupDetails(details);
|
||||
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size());
|
||||
return userLikeGroupVO;
|
||||
}
|
||||
return null;
|
||||
@@ -159,4 +172,89 @@ public class SavedCollectionController {
|
||||
return Response.success(userLikeGroupService.choose(userGroupId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "exportSave")
|
||||
@PostMapping("/exportSave")
|
||||
public Response<Boolean> exportSave(@RequestParam("file") MultipartFile file, @RequestParam("userLikeGroupId") Long userLikeGroupId) {
|
||||
return Response.success(userLikeGroupService.exportSave(file, userLikeGroupId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "exportSearch")
|
||||
@PostMapping("/exportSearch")
|
||||
public Response<JSONObject> exportSearch(@Valid @RequestBody ExportSearchDTO exportSearchDTO) {
|
||||
return Response.success(userLikeGroupService.exportSearch(exportSearchDTO.getUserLikeGroupId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "toProduct")
|
||||
@PostMapping("/toProduct")
|
||||
public Response<List<ToProductImageResult>> toProduct(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
return Response.success(userLikeGroupService.toProduct(toProductImageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "toProductImageElementUpload")
|
||||
@PostMapping("/toProductImageElementUpload")
|
||||
public Response<ToProductElementVO> toProductImageElementUpload(@RequestParam("file") MultipartFile file, @RequestParam(value = "userlikeGroupId") Long userLikeGroupId) {
|
||||
return Response.success(userLikeGroupService.toProductImageElementUpload(file, userLikeGroupId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "productImageLike")
|
||||
@PostMapping("/productImageLike")
|
||||
public Response<Boolean> productImageLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) {
|
||||
return Response.success(userLikeGroupService.productImageLike(productImageLikeDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "productImageUnLike")
|
||||
@PostMapping("/productImageUnLike")
|
||||
public Response<Boolean> productImageUnLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) {
|
||||
return Response.success(userLikeGroupService.productImageUnLike(productImageLikeDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取生成结果")
|
||||
@PostMapping("/toProductImageResult")
|
||||
public Response<List<MagicToolResultVO>> getToProductImageResult(@Valid @RequestBody List<String> taskIdList) {
|
||||
List<MagicToolResultVO> magicToolResultVOList = userLikeGroupService.getToProductImageResultList(taskIdList);
|
||||
return Response.success(magicToolResultVOList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "画布用户上传元素")
|
||||
@PostMapping("/canvasElementUpload")
|
||||
public Response<CanvasElementUpload> canvasElementUpload(@RequestParam("file") MultipartFile file) {
|
||||
return Response.success(userLikeGroupService.canvasElementUpload(file));
|
||||
}
|
||||
|
||||
@ApiOperation("productImageLikeList")
|
||||
@PostMapping("/productImageLikeList")
|
||||
public Response<List<ToProductImageResultVO>> productImageLikeList(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
return Response.success(userLikeGroupService.productImageLikeList(toProductImageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "relight")
|
||||
@PostMapping("/relight")
|
||||
public Response<List<ToProductImageResult>> relight(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
return Response.success(userLikeGroupService.relight(toProductImageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取relight结果")
|
||||
@PostMapping("/relightResult")
|
||||
public Response<List<MagicToolResultVO>> getRelightResult(@Valid @RequestBody List<String> taskIdList) {
|
||||
List<MagicToolResultVO> magicToolResultVOList = userLikeGroupService.getRelightResult(taskIdList);
|
||||
return Response.success(magicToolResultVOList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "likeHistoryRelSketch")
|
||||
@PostMapping("/likeHistoryRelSketch")
|
||||
public Response<String> likeHistoryRelSketch() {
|
||||
return Response.success(userLikeGroupService.likeHistoryRelSketch());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "download")
|
||||
@PostMapping("/download")
|
||||
public Response<String> download() {
|
||||
return Response.success(userLikeGroupService.download());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "productImageInitialize")
|
||||
@PostMapping("/productImageInitialize")
|
||||
public Response<Boolean> productImageUpload(@Valid @RequestBody ProductImageInitializeDTO productImageInitializeDTO) {
|
||||
return Response.success(userLikeGroupService.productImageInitialize(productImageInitializeDTO));
|
||||
}
|
||||
}
|
||||
|
||||
192
src/main/java/com/ai/da/controller/StripeController.java
Normal file
192
src/main/java/com/ai/da/controller/StripeController.java
Normal file
@@ -0,0 +1,192 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.common.utils.SendEmailUtil;
|
||||
import com.ai.da.mapper.primary.entity.ProductCoupons;
|
||||
import com.ai.da.model.dto.CreateCouponDTO;
|
||||
import com.ai.da.model.dto.ProductPurchaseDTO;
|
||||
import com.ai.da.model.dto.QueryCouponsPageDTO;
|
||||
import com.ai.da.model.vo.CheckCouponsVO;
|
||||
import com.ai.da.service.StripeService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.paypal.http.HttpResponse;
|
||||
import com.paypal.payments.Refund;
|
||||
import com.stripe.exception.StripeException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "Stripe模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/stripe")
|
||||
@ApiIgnore
|
||||
public class StripeController {
|
||||
|
||||
@Resource
|
||||
private StripeService stripeService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@ApiOperation("创建支付链接")
|
||||
@PostMapping("/createOrder")
|
||||
public Response<String> pay(@Valid @RequestBody ProductPurchaseDTO productPurchaseDTO, HttpServletRequest request) {
|
||||
return Response.success(stripeService.pay(productPurchaseDTO, request));
|
||||
}
|
||||
|
||||
@Value("${stripe.webhook.fail.reminder}")
|
||||
private String webhookReminderFlag;
|
||||
|
||||
@ApiOperation("支付通知")
|
||||
@PostMapping("/trade/notify")
|
||||
public void callback(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
try{
|
||||
Boolean result = stripeService.notify(request);
|
||||
if (result){
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}else {
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("Stripe Controller层异常捕捉, {}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
String key_1 = RedisUtil.STRIPE_EXCEPTION_LOG + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH);
|
||||
String key_2 = key_1 + ":" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_hh_mm_ss);
|
||||
String stackTrace = stripeService.getStackTrace(e, 10);
|
||||
redisUtil.addToString(key_2, stackTrace);
|
||||
Long size = redisUtil.getSize(key_1);
|
||||
// 给我发送邮件
|
||||
if (webhookReminderFlag.equals("1") && size == 3){
|
||||
SendEmailUtil.commonExceptionReminder("Stripe Webhook 回调", new String[]{"xupei3360@163.com"});
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("申请退款")
|
||||
@GetMapping("/trade/refund/{orderNo}/{reason}")
|
||||
public Response<HttpResponse<Refund>> refund(@PathVariable String orderNo, @PathVariable String reason) throws IOException {
|
||||
String response = stripeService.refund(null,orderNo,reason);
|
||||
if (response.equals("退款成功")){
|
||||
return Response.success();
|
||||
}else {
|
||||
return Response.fail("Request for refund failed.");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取订阅")
|
||||
@GetMapping("/getSubscription")
|
||||
public Response<List<String>> getSubscription(@RequestParam String name, @RequestParam String email) {
|
||||
try {
|
||||
return Response.success(stripeService.getSubscriptionIds(name, email));
|
||||
} catch (StripeException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("取消订阅")
|
||||
@GetMapping("/cancelSubscription")
|
||||
public Response<String> cancelSubscription(@RequestParam String subscriptionId, @RequestParam(required = false) String reason) {
|
||||
stripeService.cancelSubscription(subscriptionId, reason);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation("创建推广码")
|
||||
@PostMapping("/createCoupon")
|
||||
public Response<String> createCoupon(@Valid @RequestBody CreateCouponDTO createCouponDTO){
|
||||
return Response.success(stripeService.createCoupon(createCouponDTO));
|
||||
}
|
||||
|
||||
@ApiOperation("检查推广码")
|
||||
@GetMapping("/checkCoupon")
|
||||
public Response<CheckCouponsVO> checkCoupon(@RequestParam String promotionCode, @RequestParam Long price){
|
||||
return Response.success(stripeService.checkProductCoupon(promotionCode, price));
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有推广码")
|
||||
@PostMapping("/getAllCoupons")
|
||||
public Response<IPage<ProductCoupons>> getAllCoupons(@RequestBody QueryCouponsPageDTO queryCouponsPageDTO){
|
||||
return Response.success(stripeService.getAllCoupons(queryCouponsPageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation("检索优惠券")
|
||||
@GetMapping("/retrieveCoupon")
|
||||
public Response<String> retrieveCoupon(@RequestParam String couponId){
|
||||
return Response.success(stripeService.retrieveCoupon(couponId));
|
||||
}
|
||||
|
||||
@ApiOperation("检索推广码")
|
||||
@GetMapping("/retrievePromotionCode")
|
||||
public Response<String> retrievePromotionCode(@RequestParam String retrievePromotionCode){
|
||||
return Response.success(stripeService.retrievePromotionCode(retrievePromotionCode));
|
||||
}
|
||||
|
||||
@ApiOperation("更新推广码信息")
|
||||
@GetMapping("/updatePromCodeInfo")
|
||||
public Response<ProductCoupons> updateCouponsInfo(@RequestParam Long id, @RequestParam(required = false) String paidCommission,
|
||||
@RequestParam(required = false) String cooperator,
|
||||
@RequestParam(required = false) String remark,
|
||||
@RequestParam(required = false) Long startTime){
|
||||
return Response.success(stripeService.updateCouponsInfo(id, paidCommission, cooperator, remark, startTime));
|
||||
}
|
||||
|
||||
@ApiOperation("删除推广码")
|
||||
@GetMapping("/deletePromCode")
|
||||
public Response<String> deleteCoupon(@RequestParam Long id){
|
||||
stripeService.deleteCoupon(id);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
/*@ApiOperation("临时 取消订阅")
|
||||
@GetMapping("/cancelSubscriptionTemp")
|
||||
public Response<String> cancelSubscriptionTemp(@RequestParam String subscriptionId) {
|
||||
stripeService.cancelSubscriptionTemp(subscriptionId);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation("创建订阅 临时")
|
||||
@GetMapping("/createSubscriptionTemp")
|
||||
public Response<String> createSubscriptionTemp(@RequestParam String name, @RequestParam String email) {
|
||||
return Response.success(stripeService.createSubscriptionTemp(name, email));
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户默认支付方式 临时")
|
||||
@GetMapping("/changeCustomerPayment")
|
||||
public Response<String> changeCustomerPayment(@RequestParam String name, @RequestParam String email) {
|
||||
return Response.success(stripeService.changeCustomerPayment(name, email));
|
||||
}
|
||||
|
||||
@ApiOperation("临时 发送续订失败邮件")
|
||||
@GetMapping("/sendRenewalFailEmail")
|
||||
public Response<Boolean> sendRenewalFailEmail(@RequestParam String invoiceId, @RequestParam String subscriptionId, @RequestParam String orderNo) {
|
||||
return Response.success(stripeService.sendRenewalFailEmail(invoiceId, subscriptionId,orderNo));
|
||||
}
|
||||
|
||||
@ApiOperation("临时 查询指定用户绑定的付款方式")
|
||||
@GetMapping("/getCustomerPaymentMethod")
|
||||
public Response<List<Map<String,String>>> getCustomerPaymentMethod(@RequestParam String name, @RequestParam String email) {
|
||||
return Response.success(stripeService.getCustomerPaymentMethod(name, email));
|
||||
}
|
||||
|
||||
@ApiOperation("临时 解绑指定用户绑定的所有付款方式")
|
||||
@GetMapping("/detachCustomerAllPaymentMethod")
|
||||
public Response<String> detachCustomerAllPaymentMethod(@RequestParam String name, @RequestParam String email) {
|
||||
return Response.success(stripeService.detachCustomerAllPaymentMethod(name, email));
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
31
src/main/java/com/ai/da/controller/TagsController.java
Normal file
31
src/main/java/com/ai/da/controller/TagsController.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.Product;
|
||||
import com.ai.da.mapper.primary.entity.Tags;
|
||||
import com.ai.da.service.ProductService;
|
||||
import com.ai.da.service.TagsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@CrossOrigin //开放前端的跨域访问
|
||||
@Api(tags = "标签管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/tags")
|
||||
public class TagsController {
|
||||
|
||||
@Resource
|
||||
private TagsService tagsService;
|
||||
|
||||
@ApiOperation("获取标签")
|
||||
@GetMapping("/getTags")
|
||||
public Response<List<Tags>> getTags(@RequestParam(value = "userInput", required = false) String userInput) {
|
||||
return Response.success(tagsService.getTags(userInput));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.GoogleUser;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.AccountLoginVO;
|
||||
import com.ai.da.model.vo.DesignCollectionVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import com.ai.da.service.DesignService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -14,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.validation.Valid;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
@@ -27,11 +32,14 @@ public class ThirdPartyController {
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@ApiOperation(value = "Add user information")
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
|
||||
/*@ApiOperation(value = "Add user information")
|
||||
@PostMapping("/addUser")
|
||||
public Response<Boolean> addUser(@Valid @RequestBody AccountAddDTO accountAddDTO) {
|
||||
return Response.success(accountService.addUser(accountAddDTO));
|
||||
}
|
||||
}*/
|
||||
|
||||
@ApiOperation(value = "Edit user information")
|
||||
@PostMapping("/editUser")
|
||||
@@ -107,4 +115,35 @@ public class ThirdPartyController {
|
||||
public Response<String> getRedirectUrl() {
|
||||
return Response.success(REDIRECT_URL);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "updateNoLoginRequiredNew")
|
||||
@PostMapping("/updateNoLoginRequiredNew")
|
||||
public Response<String> updateNoLoginRequiredNew(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) {
|
||||
return Response.success(accountService.updateNoLoginRequiredNew(noLoginRequiredDTO, request));
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/auth/google_callback")
|
||||
public Response<String> googleCallback(@RequestParam("code") String code, HttpSession session) {
|
||||
return Response.success(accountService.googleCallback(code, session));
|
||||
}
|
||||
@CrossOrigin
|
||||
@GetMapping("/parseGoogleCredential")
|
||||
public Response<AccountLoginVO> parseGoogleCredential(@RequestParam("credential") String credential, @RequestParam("type") Integer type) {
|
||||
return Response.success(accountService.parseGoogleCredential(credential, type));
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/parseWeChatCode")
|
||||
public Response<AccountLoginVO> parseWeChatCode(@RequestParam("code") String code, @RequestParam("type") Integer type) {
|
||||
return Response.success(accountService.parseWeChatCode(code, type));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收Design结果")
|
||||
@PostMapping("/receiveDesignResults")
|
||||
@CrossOrigin
|
||||
public Response<Boolean> receiveDesignResults(@Valid @RequestBody JSONObject responseObject) {
|
||||
return Response.success(designService.receiveDesignResults(responseObject));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
import com.ai.da.model.vo.ModelsVO;
|
||||
import com.ai.da.model.vo.StyleVO;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -44,8 +47,8 @@ public class WorkspaceController {
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "详情", notes = "传入workspace")
|
||||
public Response<Workspace> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
||||
Workspace detail = workspaceService.getByIdNew(id);
|
||||
public Response<WorkspaceVO> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
||||
WorkspaceVO detail = workspaceService.getByIdNew(id);
|
||||
return Response.success(detail);
|
||||
}
|
||||
|
||||
@@ -66,8 +69,8 @@ public class WorkspaceController {
|
||||
@PostMapping("/saveOrUpdate")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "新增或编辑", notes = "传入workspace")
|
||||
public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) {
|
||||
return Response.success(workspaceService.saveOrUpdate(workspace));
|
||||
public Response saveOrUpdate(@Valid @RequestBody WorkspaceSaveDTO workspaceDTO) {
|
||||
return Response.success(workspaceService.saveOrUpdate(workspaceDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +95,8 @@ public class WorkspaceController {
|
||||
@GetMapping("/getMannequins")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperation(value = "获取模特")
|
||||
public Response<List<ModelsVO>> getMannequins(@RequestParam("sex") String sex) {
|
||||
List<ModelsVO> modelsVO = workspaceService.getMannequins(sex);
|
||||
public Response<List<ModelsVO>> getMannequins(@RequestParam("sex") String sex, @RequestParam("style") String style) {
|
||||
List<ModelsVO> modelsVO = workspaceService.getMannequins(sex, style);
|
||||
return Response.success(modelsVO);
|
||||
}
|
||||
|
||||
@@ -115,10 +118,17 @@ public class WorkspaceController {
|
||||
}
|
||||
|
||||
@PostMapping("maleDataInsert")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@ApiOperationSupport(order = 8)
|
||||
@ApiOperation(value = "男装数据入库入minio")
|
||||
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
|
||||
workspaceService.maleDataInsert();
|
||||
return Response.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("styleList")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@ApiOperation(value = "获取style列表")
|
||||
public Response<List<StyleVO>> styleList() {
|
||||
return Response.success(workspaceService.styleList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.AccountExtend;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface AccountExtendMapper extends CommonMapper<AccountExtend> {
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -27,6 +28,8 @@ public interface AccountMapper extends CommonMapper<Account> {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Account findById(String id);
|
||||
// Account findById(String id);
|
||||
|
||||
void toVisitor(Long id);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.AffiliateIncome;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AffiliateIncomeMapper extends BaseMapper<AffiliateIncome> {
|
||||
|
||||
List<Map<String, Object>> getPersonalMonthlyIncome(Long affiliateAccountId, int year);
|
||||
|
||||
List<Map<String, Object>> getMonthlyAffiliateIncome(int year, int month);
|
||||
}
|
||||
19
src/main/java/com/ai/da/mapper/primary/AffiliateMapper.java
Normal file
19
src/main/java/com/ai/da/mapper/primary/AffiliateMapper.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Affiliate;
|
||||
import com.ai.da.model.vo.AffiliateVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AffiliateMapper extends BaseMapper<Affiliate> {
|
||||
|
||||
Map<String, Long> getMonthlyApprovedAffiliate(int year, int month);
|
||||
|
||||
List<AffiliateVO> getAffiliateList(String status, String startTime, String endTime,
|
||||
String order, Long affiliateId, int size, int offset);
|
||||
|
||||
int queryAffiliateTotalCount(String status, String startTime, String endTime, Long affiliateId);
|
||||
|
||||
}
|
||||
7
src/main/java/com/ai/da/mapper/primary/CanvasMapper.java
Normal file
7
src/main/java/com/ai/da/mapper/primary/CanvasMapper.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Canvas;
|
||||
|
||||
public interface CanvasMapper extends CommonMapper<Canvas> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Comment;
|
||||
|
||||
public interface CommentMapper extends CommonMapper<Comment> {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.AccountExtend;
|
||||
import com.ai.da.mapper.primary.entity.DesignBatch;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignBatchMapper extends CommonMapper<DesignBatch> {
|
||||
|
||||
|
||||
}
|
||||
@@ -18,5 +18,5 @@ public interface DesignMapper extends CommonMapper<Design> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertDesign(Design design);
|
||||
|
||||
List<UserDesignStatisticDTO> getDesignStatistic(String startTime, String endTime);
|
||||
List<UserDesignStatisticDTO> getDesignStatistic(String startTime, String endTime, List<Long> ids, String email);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ExportFile;
|
||||
|
||||
public interface ExportFileMapper extends CommonMapper<ExportFile> {
|
||||
}
|
||||
@@ -3,5 +3,10 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Generate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GenerateMapper extends CommonMapper<Generate> {
|
||||
|
||||
List<Map<String, Object>> getByTypeAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.MoodboardPosition;
|
||||
|
||||
public interface MoodboardPositionMapper extends CommonMapper<MoodboardPosition> {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Notification;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface NotificationMapper extends CommonMapper<Notification> {
|
||||
|
||||
List<Map<String, Object>> getTypeCount(Long receiverId);
|
||||
|
||||
/** 解决mybatis-plus自动过滤 is_deleted为1的数据 问题 */
|
||||
Notification getUniqueLikeAndFollow(String type, Long senderId, Long receiverId, Long portfolioId);
|
||||
|
||||
void updateUniqueLikeAndFollow(Long id, LocalDateTime time);
|
||||
|
||||
void deleteNotification(Long id, LocalDateTime time);
|
||||
|
||||
void setPersonalNotificationAllRead(String type, Long receiverId, LocalDateTime time);
|
||||
|
||||
List<Long> getUnreadSysNotification(Long accountId);
|
||||
}
|
||||
@@ -1,7 +1,39 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.PaymentInfo;
|
||||
import com.ai.da.model.vo.OrderListVO;
|
||||
import com.ai.da.model.vo.PaymentInfoVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PaymentInfoMapper extends BaseMapper<PaymentInfo> {
|
||||
|
||||
List<OrderListVO> selectPageOrderList(Long accountId, String startTime, String endTime, int offset, int pageSize, Long id);
|
||||
|
||||
int queryOrderListTotalCount(Long accountId, String startTime, String endTime, Long id);
|
||||
|
||||
List<PaymentInfoVO> queryPaymentInfo(String paymentType,String payerTotal, String type, String status,
|
||||
String country, String city, String startTime, String endTime,
|
||||
int limit, int offset, String order, String payer
|
||||
);
|
||||
|
||||
Long queryPaymentInfoCount(String paymentType,String payerTotal, String type, String status,
|
||||
String country, String city, String startTime, String endTime, String payer
|
||||
);
|
||||
|
||||
BigDecimal queryTotalPaymentAmount(String paymentType,String payerTotal, String type, String status,
|
||||
String country, String city, String startTime, String endTime, String payer
|
||||
);
|
||||
|
||||
List<Map<String, String>> getCities();
|
||||
|
||||
List<Map<String, String>> getCountries();
|
||||
|
||||
int insertIgnore(@Param("paymentInfo")PaymentInfo paymentInfo);
|
||||
|
||||
List<PaymentInfo> selectPaidPaymentsByAccountAndPromotion(Long accountId, String promotionCode);
|
||||
}
|
||||
|
||||
12
src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java
Normal file
12
src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Portfolio;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PortfolioMapper extends CommonMapper<Portfolio> {
|
||||
Portfolio getByIdAll(Long originalPortfolioId);
|
||||
|
||||
List<Portfolio> getByTag(Long accountId, String tagName);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.PortfolioTags;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public interface PortfolioTagsMapper extends CommonMapper<PortfolioTags> {
|
||||
|
||||
void deleteByPortfolioId(Long portfolioId);
|
||||
|
||||
// portfolioId与tagId建立唯一约束, 如果组合 portfolio_id 和 tag_id 已经存在,插入操作会被忽略。
|
||||
void insertIgnore(Long portfolioId, Long tagId, LocalDateTime time);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ProductCoupons;
|
||||
|
||||
public interface ProductCouponsMapper extends CommonMapper<ProductCoupons> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ProductImageAttribute;
|
||||
|
||||
public interface ProductImageAttributeMapper extends CommonMapper<ProductImageAttribute> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
|
||||
public interface QuestionnaireMapper extends CommonMapper<Questionnaire> {
|
||||
}
|
||||
17
src/main/java/com/ai/da/mapper/primary/StyleMapper.java
Normal file
17
src/main/java/com/ai/da/mapper/primary/StyleMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface StyleMapper extends CommonMapper<Style> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.SubscriptionInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface SubscriptionInfoMapper extends BaseMapper<SubscriptionInfo> {
|
||||
int insertIgnore(@Param("subscriptionInfo") SubscriptionInfo subscriptionInfo);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.SysNotificationReadStatus;
|
||||
|
||||
public interface SysNotificationReadStatusMapper extends CommonMapper<SysNotificationReadStatus> {
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.TDesignPythonOutfitDetail;
|
||||
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,4 +26,7 @@ public interface TDesignPythonOutfitDetailMapper extends CommonMapper<TDesignPyt
|
||||
*/
|
||||
List<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
|
||||
|
||||
@Delete("DELETE FROM t_design_python_outfit_detail WHERE design_python_outfit_id = #{designPythonOutfitId}")
|
||||
void deleteByDesignPythonOutfitIdPhysical(@Param("designPythonOutfitId") Long designPythonOutfitId);
|
||||
|
||||
}
|
||||
|
||||
17
src/main/java/com/ai/da/mapper/primary/TagsMapper.java
Normal file
17
src/main/java/com/ai/da/mapper/primary/TagsMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Tags;
|
||||
import com.ai.da.model.dto.TagsDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface TagsMapper extends CommonMapper<Tags> {
|
||||
|
||||
List<Map<String, String>> getMatchingTags(String userInput);
|
||||
|
||||
List<TagsDTO> getTagByPortfolioId(Long portfolioId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ToProductElement;
|
||||
|
||||
public interface ToProductElementMapper extends CommonMapper<ToProductElement> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ToProductImageRecord;
|
||||
|
||||
public interface ToProductImageRecordMapper extends CommonMapper<ToProductImageRecord> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ToProductImageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ToProductImageResultMapper extends CommonMapper<ToProductImageResult> {
|
||||
|
||||
List<Map<String, Object>> getByTypeAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
@@ -11,6 +14,6 @@ import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
*/
|
||||
public interface TrialOrderMapper extends CommonMapper<TrialOrder> {
|
||||
|
||||
|
||||
Map<String, Long> countOfficialUser();
|
||||
|
||||
}
|
||||
|
||||
19
src/main/java/com/ai/da/mapper/primary/UserFollowMapper.java
Normal file
19
src/main/java/com/ai/da/mapper/primary/UserFollowMapper.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserFollow;
|
||||
import com.ai.da.model.vo.AccountFollowVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface UserFollowMapper extends CommonMapper<UserFollow> {
|
||||
List<AccountFollowVO> getFolloweeListByFollower(Long followerAccountId, Integer limit, Integer offset, String order);
|
||||
|
||||
List<AccountFollowVO> getFollowerListByFollowee(Long followeeAccountId, Integer limit, Integer offset, String order);
|
||||
|
||||
List<AccountFollowVO> getFolloweeListByName(String name, Long followerId);
|
||||
|
||||
List<AccountFollowVO> getFollowerListByName(String name, Long followeeId);
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserLike;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeSort;
|
||||
|
||||
public interface UserLikeSortMapper extends CommonMapper<UserLikeSort> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.WorkspaceRelStyle;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface WorkspaceRelStyleMapper extends CommonMapper<WorkspaceRelStyle> {
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.ai.da.mapper.primary.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -56,6 +58,11 @@ public class Account implements Serializable {
|
||||
*/
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 职业
|
||||
*/
|
||||
private String occupation;
|
||||
|
||||
/**
|
||||
* 账户有效期开始时间
|
||||
*/
|
||||
@@ -69,11 +76,13 @@ public class Account implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateDate;
|
||||
|
||||
private Integer isTrial;
|
||||
@@ -86,4 +95,44 @@ public class Account implements Serializable {
|
||||
* 积分
|
||||
*/
|
||||
private BigDecimal credits;
|
||||
|
||||
/**
|
||||
* 用于区分游客与系统用户
|
||||
* 0 : 游客
|
||||
* 1 : 年付用户
|
||||
* 2 : 月付用户
|
||||
* 3 : 试用用户
|
||||
* 4 : 参加活动获取30天有效期和6000个积分的用户
|
||||
* 5 : 企业管理员账号
|
||||
* 6 : 企业子账号
|
||||
* 7 : 学校管理员
|
||||
* 8 : 学校子账号
|
||||
*/
|
||||
private Integer systemUser;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
private String organizationName;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private Integer isAdmin;
|
||||
|
||||
private BigDecimal shareCredits;
|
||||
|
||||
private Integer subAccountNum;
|
||||
|
||||
private String invitationCode;
|
||||
|
||||
@ApiModelProperty("title")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("surname")
|
||||
private String surname;
|
||||
|
||||
@ApiModelProperty("givenName")
|
||||
private String givenName;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.ai.da.common.response.PageResponse;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("account_extend")
|
||||
public class AccountExtend implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long accountId;
|
||||
|
||||
private String authType;
|
||||
|
||||
private String headImgUrl;
|
||||
|
||||
private String name;
|
||||
|
||||
private String auth;
|
||||
}
|
||||
32
src/main/java/com/ai/da/mapper/primary/entity/Affiliate.java
Normal file
32
src/main/java/com/ai/da/mapper/primary/entity/Affiliate.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("t_affiliate")
|
||||
public class Affiliate extends BaseEntity{
|
||||
|
||||
private Long accountId;
|
||||
|
||||
// Active(活跃) || Inactive(过期) || Pending(待审批) || Refused(拒绝)
|
||||
private String status;
|
||||
|
||||
private Float commissionPercent;
|
||||
|
||||
private Float totalEarnings = 0.00F;
|
||||
|
||||
private Float monthlyEarnings = 0.00F;
|
||||
|
||||
private Float unpaidEarnings = 0.00F;
|
||||
|
||||
private Integer visits = 0;
|
||||
|
||||
private Boolean approved = false;
|
||||
|
||||
private String link;
|
||||
|
||||
private String promotionMethod;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user