code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE_2024_36939 { meta: date="2024-12-06" openharmony_sa="" cve="CVE-2024-36939" affected_files="/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {?? ?? 37 94 80 00 00 B4 E0 03 13 AA ?? D5 FF 97 04 00 00 14 E0 03 13 AA ?? D5 FF 97 60 01 80 12} condition: $fix and console.log("CVE-2024-36939 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/08/CVE-2024-36939/TestCaseRule-CVE-2024-36939.yara
YARA
unknown
1,065
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_CVE_2024_36940 { meta: date="2024-12-10" file="" strings: $fix={60 2A 40 F9 01 A4 00 ?0 21 ?? ?? 91 E2 03 14 2A ?? ?? 0A 94 E7 FF FF 17} $nofix={68 0A 40 F9 E0 03 13 AA 01 05 40 F9 02 11 40 B9 10 00 00 94 E0 03 13 AA} condition: $fix and not $nofix and console.log("TestCaseRule_CVE-2024-36940 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/08/CVE-2024-36940/TestCaseRule-CVE-2024-36940.yara
YARA
unknown
1,057
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_CVE_2024_36941 { meta: data = "2024-12-07" openharmony_sa = "" cve = "CVE-2024-36941" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix_version = {A9 02 00 B4 77 56 14 9B} condition: // 匹配 5.0 版本的机器码并输出信息 $fix_version and console.log("CVE-2024-36941 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/08/CVE-2024-36941/TestCaseRule-CVE-2024-36941.yara
YARA
unknown
1,104
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_CVE_2024_4603 { meta: date="2024-11-14" file="" strings: $fix={70 B5 05 46 80 68 0C 46 00 28 1C BF E9 68 00 29 02 D1 72 25 19 26 15 E0} condition: $fix and console.log("TestCaseRule_CVE_2024_4603 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/08/CVE-2024-4603/TestCaseRule-CVE-2024-4603.yara
YARA
unknown
955
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_25739 { meta: date = "2024-02-12" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = "LEB size too small for a volume record" condition: $fix and console.log("OpenHarmony-CVE-2024-25739 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-25739/TestCaseRule-OpenHarmony-CVE-2024-25739.yara
YARA
unknown
1,013
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_26585 { meta: date = "2024-02-21" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $vul = {48 FA FF B4 09 C0 19 D1 2A 00 80 52 2A 01 00 B9 BF 3B 03 D5 89 56 40 F9 1F 01 09 EB F5 17 9F 1A} $fix = {E0 03 08 AA 81 3A 00 B9 45 EF FF 97} condition: ((not $vul) or $fix) and console.log("OpenHarmony-CVE-2024-26585 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-26585/TestCaseRule-OpenHarmony-CVE-2024-26585.yara
YARA
unknown
1,140
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE202436270 { meta: date="2024-12-29" openharmony_sa="" cve="CVE-2024-36270" affected_files="/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {08 FD DF C8 88 01 00 B4 08 41 00 91 08 FD DF C8} $vul = {08 FD DF C8 08 41 00 91 08 FD DF C8 28 01 00 B4} condition: ((not $vul) and $fix) and console.log("CVE-2024-36270 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-36270/TestCaseRule-OpenHarmony-CVE-2024-36270.yara
YARA
unknown
1,094
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" import "elf" rule CVE_2024_38564 { meta: date = "2024-12-18" openharmony_sa = "" cve = "CVE-2024-38564" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {e0 03 13 2a ?? ?? ?? ?? 88 06 40 b9 1f 01 00 6b} condition: $fix and console.log("CVE-2024-38564 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-38564/TestCaseRule-CVE-2024-38564.yara
YARA
unknown
1,030
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE_2024_38577 { meta: date="2024-12-06" openharmony_sa="" cve="CVE-2024-38577" affected_files="/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {45 5D 41 F9 06 61 41 F9 E0 23 00 91 01 08 80 52 ?? ?? 19 94} condition: $fix and console.log("CVE-2024-38577 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-38577/TestCaseRule-CVE-2024-38577.yara
YARA
unknown
1,028
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE_2024_38588 { meta: date="2024-12-06" openharmony_sa="" cve="CVE-2024-38588" affected_files="/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {93 00 00 B4 ?? 4D FE 97 E0 03 13 AA 1D 00 00 94} condition: $fix and console.log("CVE-2024-38588 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-38588/TestCaseRule-CVE-2024-38588.yara
YARA
unknown
1,020
/*     * Copyright (c) 2024 Beijing University of Posts and Telecommunications.   *     * Licensed under the Apache License, Version 2.0 (the "License");     * you may not use this file except in compliance with the License.     * You may obtain a copy of the License at     *     * http://www.apache.org/licenses/LICENSE-2.0     *     * Unless required by applicable law or agreed to in writing, software     * distributed under the License is distributed on an "AS IS" BASIS,     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.     * See the License for the specific language governing permissions and     * limitations under the License.     */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_38601 { meta: date = "2023-03-08" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {?? ?? 50 94 F9 03 00 AA E0 03 17 AA ?? ?? 00 94 E0 03 18 AA E1 03 19 AA ?? ?? 50 94} condition: $fix and console.log("OpenHarmony-CVE-2024-38601 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-38601/TestCaseRule-OpenHarmony-CVE-2024-38601.yara
YARA
unknown
1,083
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_CVE_2024_5535 { meta: date="2024-11-15" openharmony_sa="" cve="CVE-2024-5535" affected_files="/system/lib/chipset-pub-sdk/libssl_openssl.z.so" strings: $fix = {?? F1 01 00 ?? F8 00 00 0B 70 ?? D4} condition: $fix and console.log("CVE-2024-5535 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/CVE-2024-5535/TestCaseRule-CVE-2024-5535.yara
YARA
unknown
1,038
/* *Copyright (c) 2024 Beijing University of Posts and Telecommunications. *Licensed under the Apache License, Version 2.0 (the "License"); *you may not use this file except in compliance with the License. *You may obtain a copy of the License at *http://www.apache.org/licenses/LICENSE-2.0 *Unless required by applicable law or agreed to in writing, software *distributed under the License is distributed on an "AS IS" BASIS, *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *See the License for the specific language governing permissions and *limitations under the License. */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_42114 { meta: date = "2024-07-12" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $vul = {69 6E 6F 64 65 20 28 69 6E 6F 3D} $fix = {69 6E 6F 64 65 20 28 69 6E 6F 3D 25 6C 78 29 20 68 61 73 20 63 6F 72 72 75 70 74 65 64 20 69 5F 78 61 74 74 72 5F 6E 69 64 3A 20 25 75 2C 20 72 75 6E 20 66 73 63 6B 20 74 6F 20 66 69 78 2E 00} condition: ((not $vul) or $fix) and console.log("OpenHarmony-CVE-2024-39467 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/09/OpenHarmony-CVE-2024-39467/TestCaseRule-OpenHarmony-CVE-2024-39467.yara
YARA
unknown
1,184
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" import "elf" rule CVE_2023_52672 { meta: date = "2024-12-18" openharmony_sa = "" cve = "CVE-2023-52672" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $vul = {f8 37 b5 4e 14 12 74 92 00 b9 74 9a 00 b9} condition: (not $vul) and console.log("CVE-2023-52672 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE-2023-52672/TestCaseRule-CVE-2023-52672.yara
YARA
unknown
1,029
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_35947 { meta: date = "2024-05-19" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = "parse err after word:%d=%s\n" condition: $fix and console.log("OpenHarmony-CVE-2024-35947 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE-2024-35947/TestCaseRule-OpenHarmony-CVE-2024-35947.yara
YARA
unknown
1,003
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE_2024_40971 { meta: date="2024-12-10" openharmony_sa="" cve="CVE_2024_40971" affected_files="" strings: $fix = {68 92 47 B9 ?? ?? ?? ?? 49 00 80 52 75 C2 1F 39 7F E2 1F 39 F5 0B 40 F9} condition: $fix and console.log("CVE_2024_40971 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE-2024-40971/CVE-2024-40971.yara
YARA
unknown
984
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE_2024_41035 { meta: date="2024-12-19" openharmony_sa="" cve="CVE-2024-41035" affected_files="/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix="config %d interface %d altsetting %d has an endpoint descriptor with address 0x%X, changing to 0x%X" condition: $fix and console.log("CVE-2024-41035 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE-2024-41035/TestCaseRule-CVE-2024-41035.yara
YARA
unknown
1,068
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestcaseRule_OpenHarmony_CVE-2024-41087 { meta: date = "2024-10" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = {E0 03 13 AA ?? ?? DF 97 04 00 00 14} $vul = {E0 03 13 AA F5 76 DF 97} condition: ((not $vul) and $fix) and console.log("CVE-2024-41087 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE-2024-41087/TestcaseRule-OpenHarmony-CVE-2024-41087.yara
YARA
unknown
1,057
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestcaseRule_OpenHarmony_CVE_2024_42236 { meta: date = "2024-10" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = { 8B 02 00 54 14 01 00 B5 ?? ?? ?? ?? 01 98 81 52 E2 0F 80 52 00 ?? ?? ?? ?? ?? D6 97 F4 03 00 AA C0 01 00 B4 E0 03 14 AA E1 03 15 AA ?? ?? E9 97 C8 06 00 51 89 4A 68 38 3F 29 00 71 41 00 00 54 9F 6A 28 38 E0 03 1F 2A 74 02 00 F9 04 00 00 14 A0 02 80 12 } condition: $fix and console.log("CVE-2024-42236 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE-2024-42236/TestcaseRule-CVE-2024-42236.yara
YARA
unknown
1,305
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule CVE_2024_42115 { meta: date="2024-10" openharmony_sa="" cve="CVE_2024_42115" affected_files="/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $vul = {60 C2 01 91 ?? ?? F8 97} $fix = {60 C2 01 91 7F 2E 00 F9 ?? ?? F8 97} condition: ((not $vul) or $fix) and console.log("CVE-2024-42115 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/CVE_2024_42115/TestCaseRule-CVE-2024-42115.yara
YARA
unknown
1,087
/* *Copyright (c) 2024 Beijing University of Posts and Telecommunications. *Licensed under the Apache License, Version 2.0 (the "License"); *you may not use this file except in compliance with the License. *You may obtain a copy of the License at *http://www.apache.org/licenses/LICENSE-2.0 *Unless required by applicable law or agreed to in writing, software *distributed under the License is distributed on an "AS IS" BASIS, *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *See the License for the specific language governing permissions and *limitations under the License. */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_42114 { meta: date = "2024-09-26" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $vul = {A8 82 23 91 F3 03 00 AA 08 FD DF C8 16 01 40 F9 C8 52 41 39} $fix = {D6 C2 00 91 F3 03 00 AA E0 03 16 AA 0F 40 51 94 A8 82 23 91 09 41 38 D5 08 FD DF C8 E1 03 13 AA} condition: ((not $vul) or $fix) and console.log("OpenHarmony-CVE-2024-42114 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/10/OpenHarmony-CVE-2024-42114/TestCaseRule-OpenHarmony-CVE-2024-42114.yara
YARA
unknown
1,113
/* * Copyright (c) 2024 Beijing University of Posts and Telecommunications. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_OpenHarmony_CVE_2024_26684 { meta: date = "2024-02-19" file = "/dev/block/platform/fe310000.sdhci/by-name/boot_linux" strings: $fix = "Read Rx Descriptor Parity checker Error" condition: $fix and console.log("OpenHarmony-CVE-2024-26684 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2024/12/CVE-2024-26684/TestCaseRule-OpenHarmony-CVE-2024-26684.yara
YARA
unknown
1,016
/* * Copyright (c) 2025 Beijing University Of Posts and Telecommunications. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "console" rule TestCaseRule_CVE_2025_21817 { meta: date = "2025-11-28" openharmony_sa = "" cve = "CVE-2025-21817" severity = "medium" component = "kernel_linux_5.10" affected_version = "OpenHarmony-v5.0.3-Release" fix_commit = "b36c9fbe92dcdaec48fefc27ac9a076704a6ec21" strings: // 修复前的易受攻击模式(nf_hook_slow 越界读典型特征) $vuln_pattern = { 48 8B 4? ?? 48 8D 41 FF 48 39 0A 0F 87 } // 修复后的安全模式(增加了边界检查或直接删除了危险代码) $fixed_pattern = { 48 8B 4? ?? 48 83 C1 FF 48 39 0A 0F 82 } condition: $vuln_pattern and not $fixed_pattern and console.log("CVE-2025-21817 testcase pass") }
2301_80000730/security_2000
vulntest/SSTSTestcases/2025/01/CVE-2025-21817/CVE-2025-21817.yara
YARA
unknown
1,513
import { hapTasks } from '@ohos/hvigor-ohos-plugin'; export default { system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ }
2301_80000730/security_2000
vulntest/vultraining/entry/hvigorfile.ts
TypeScript
unknown
234
import { appTasks } from '@ohos/hvigor-ohos-plugin'; export default { system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ }
2301_80000730/security_2000
vulntest/vultraining/hvigorfile.ts
TypeScript
unknown
234
# Build pg_trace_tool, need pg_config support EXTENSION = pg_trace_tool EXTVERSION = 1.0 DATA = pg_trace_tool--1.0.sql MODULE_big = pg_trace_tool OBJS = pg_trace_tool.o # PGXS USE_PGXS = 1 PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS)
2301_80257615/pg_trace_tool
makefile
Makefile
unknown
268
/* * pg_trace_tool.c * * A trace tool for OpenTenBase that can be used to track and analyze the execution of Functions and Procedures. * Supported features: * 1. Track and analyze Function and Procedure execution * 2. Generate execution reports for Functions and Procedures * * Author: CDUESTC Open Atom Open Source Club * Version: 1.0 */ #include "c.h" #include "postgres.h" #include "fmgr.h" #include "executor/executor.h" #include "executor/execdesc.h" #include "utils/timestamp.h" #include "utils/memutils.h" #include "utils/builtins.h" #include "catalog/pg_proc.h" #include "utils/syscache.h" #include "catalog/namespace.h" #include "catalog/pg_type.h" #include "access/htup.h" #include "parser/parse_func.h" #include "utils/elog.h" #include "pg_trace_tool.h" PG_MODULE_MAGIC; /* 跟踪信息结构体 单向链表 */ typedef struct TraceEntry { /* 函数名称 */ char *function_name; /* SQL文本 */ char *sql_text; /* 执行时间 */ TimestampTz exec_time; /* 下一个结构体 */ struct TraceEntry *next; } TraceEntry; /* 全局变量 */ static TraceEntry *trace_list = NULL; /* 原有的钩子函数 */ static ExecutorStart_hook_type prev_ExecutorStart = NULL; static ExecutorRun_hook_type prev_ExecutorRun = NULL; /* 当前正在执行的function的名称 */ static char *current_function_name = NULL; /** 辅助函数:获取指定类型的输入函数。 @param type_oid 要查询的类型的oid。如text、int32等的oid。 @return Oid 对应类型的输入函数的oid */ static Oid get_type_input_function(Oid type_oid) { /* 存储从系统缓存里查询到的元组 */ HeapTuple tup; /* 保存结果,即输入函数的OID */ Oid input_func; /* 根据oid,从系统的pg_type表里查找对应的输入函数类型 ObjectIdGetDatum函数用于将OID转换为Datum类型用于查询 */ tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("The type with Oid %u does not exist", type_oid))); input_func = ((Form_pg_type) tup->t_data)->typinput; ReleaseSysCache(tup); return input_func; } /** 辅助函数:获取函数参数类型。 @param func_oid 要查询参数类型的function的OID @param argnum 要获取的参数的索引 @return Oid 指定函数中指定参数的类型 */ static Oid get_func_argtype(Oid func_oid, int argnum) { HeapTuple tup; /* pg_proc表存放数据库的function和procedure等信息 proc变量用于存储指定function/procedure的元数据 */ Form_pg_proc proc; /* 保存结果。即指定function中某参数的类型oid */ Oid argtype; /* 根据oid,从pg_proc里查询指定function的元数据 */ tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_oid)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("The function with Oid %u does not exist", func_oid))); /* 将查询到的指定function的元数据存储在proc中 */ proc = (Form_pg_proc) tup->t_data; /* proc->pronargs属性为参数个数 当给定的参数索引大于参数个数时,抛出错误 */ if (argnum >= proc->pronargs) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("The function %s does not have %d arguments", NameStr(proc->proname), argnum + 1))); argtype = proc->proargtypes.values[argnum]; ReleaseSysCache(tup); return argtype; } /** 钩子函数。在查询执行器开始运行时进行跟踪。 @param queryDesc 这个结构体里包含原始SQL文本与执行查询所需的所有上下文信息 @param eflags 控制查询行为的标志 @return 无 */ static void trace_executor_start(QueryDesc *queryDesc, int eflags) { /* 获取查询开始执行的时间 */ TimestampTz start_time = GetCurrentTimestamp(); /* 用于跟踪function/procedure执行过程的结构体 */ TraceEntry *entry; /* 用于保存现有的内存上下文 */ MemoryContext old_context; if (!queryDesc || !queryDesc->sourceText) return; /* 切换到全局内存上下文,否则无法长期保存跟踪信息 */ old_context = MemoryContextSwitchTo(TopMemoryContext); PG_TRY(); { /* 记录查询开始信息 */ entry = palloc(sizeof(TraceEntry)); /* 内存分配失败 */ if (!entry) { MemoryContextSwitchTo(old_context); ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("Memory allocation failed: unable to allocate memory for query tracking entry"), errdetail("Current memory context: %s", old_context->name))); } /* 获取原始SQL文本、开始时间、function名称 */ entry->sql_text = pstrdup(queryDesc->sourceText); entry->exec_time = start_time; entry->function_name = pstrdup(current_function_name ? current_function_name : "Unknown"); entry->next = trace_list; trace_list = entry; /* 调用其他钩子 */ if (prev_ExecutorStart) prev_ExecutorStart(queryDesc, eflags); else standard_ExecutorStart(queryDesc, eflags); } PG_CATCH(); { /* 出错后清理资源 */ if (entry) { if (entry->sql_text) pfree(entry->sql_text); if (entry->function_name) pfree(entry->function_name); pfree(entry); } /* 切换回原来的内存上下文 */ MemoryContextSwitchTo(old_context); PG_RE_THROW(); } PG_END_TRY(); MemoryContextSwitchTo(old_context); } /** 钩子函数。在查询执行器的运行阶段插入,确保数据库的查询执行链不断裂。 */ static void trace_executor_run(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once) { /* 调用原始钩子 */ if (prev_ExecutorRun) prev_ExecutorRun(queryDesc, direction, count, execute_once); else standard_ExecutorRun(queryDesc, direction, count, execute_once); } /** 清理跟踪数据,释放跟踪信息结构体的内存。 */ static void cleanup_trace_data(void) { TraceEntry *entry = trace_list; while (entry != NULL) { TraceEntry *next = entry->next; pfree(entry->sql_text); pfree(entry->function_name); pfree(entry); entry = next; } trace_list = NULL; } /** 生成跟踪报告。 */ static char* generate_trace_report(void) { /* 报告结果字符串 */ StringInfoData str; /* 跟踪信息结构体链表 */ TraceEntry *entry; /* 记录执行节点个数 */ int entry_count = 0; initStringInfo(&str); appendStringInfoString(&str, "函数执行跟踪报告\n"); appendStringInfoString(&str, "==================\n\n"); /* 便利跟踪信息结构体链表,将跟踪得到的数据写入结果字符串中 */ entry = trace_list; while (entry != NULL) { entry_count++; appendStringInfo(&str, "执行记录 #%d:\n", entry_count); appendStringInfo(&str, "----------------\n"); appendStringInfo(&str, "函数名称: %s\n", entry->function_name); appendStringInfo(&str, "SQL语句: %s\n", entry->sql_text); appendStringInfo(&str, "执行时间: %s\n", timestamptz_to_str(entry->exec_time)); appendStringInfoString(&str, "\n"); entry = entry->next; } if (entry_count == 0) { appendStringInfoString(&str, "没有找到任何执行记录\n"); } else { appendStringInfo(&str, "总计执行记录数: %d\n", entry_count); } return str.data; } /** 解析函数参数。 @param func_call_str 指定function的调用语句字符串 @return List 指定function的参数列表指针 */ static List *parse_function_arguments(const char *func_call_str) { /* 保存结果。即指定function的参数列表 */ List *args = NIL; /* 保存function调用语句字符串中的参数部分 */ char *args_str; /* 临时存储当前正在解析的参数字符串,为NULL时代表解析完毕 */ char *tmpToken; /* 在分割参数字符串时,记录分割的进度 */ char *saveptr; /* function的调用字符串中参数部分的结束指针 */ char *end; /* 以左括号为起点开始提取参数部分,并跳过左括号 */ args_str = strchr(func_call_str, '('); if (!args_str) return NIL; args_str++; /* 找到右括号 */ end = strrchr(args_str, ')'); if (!end) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid function call syntax: missing closing parenthesis"))); /* 截取字符串 */ *end = '\0'; /* 至此args_str中存储的是function调用字符串中的参数部分。 假设有function:my_function(1, 'hello') 则此时args_str为 {'1', ',', ' ', 'h', 'e', 'l', 'l', 'o'}。 */ /* 按逗号分割参数 */ tmpToken = strtok_r(args_str, ",", &saveptr); while (tmpToken != NULL) { /* 去除空白字符 */ while (isspace(*tmpToken)) tmpToken++; /* 将参数字符串添加到List */ args = lappend(args, makeString(pstrdup(tmpToken))); tmpToken = strtok_r(NULL, ",", &saveptr); } return args; } /** 解析函数调用字符串,返回该函数的Oid。同时解析该function的参数列表。 @param func_call_str 指定function的调用字符串 @param args 指定function的参数列表的指针 @return Oid 指定function的Oid */ static Oid parse_function_call(const char *func_call_str, List **args) { /* 存储函数名称,使用链表是因为函数调用时有可能使用schema.func的形式 */ List *names; /* 存储结果。即指定function的Oid */ Oid func_oid; /* 存储指定function的参数类型列表 */ Oid *argtypes; /* 记录指定function的参数个数 */ int nargs; char *func_name; char *func_name_copy; func_name_copy = pstrdup(func_call_str); /* 第一个小括号前的部分即为function字符串 */ func_name = strtok(func_name_copy, "("); if (!func_name) { pfree(func_name_copy); ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid function call syntax"))); } /* 将得到的字符串转换为函数名称链表 */ names = stringToQualifiedNameList(func_name); if (names == NIL) { pfree(func_name_copy); ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("invalid function call syntax"))); } /* 解析参数 */ *args = parse_function_arguments(func_call_str); nargs = list_length(*args); /* 根据函数名称、参数数量与参数类型列表查找函数Oid */ argtypes = palloc0(nargs * sizeof(Oid)); func_oid = LookupFuncName(names, nargs, argtypes, false); pfree(argtypes); if (func_oid == InvalidOid) { pfree(func_name_copy); ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function %s does not exist", NameListToString(names)))); } pfree(func_name_copy); return func_oid; } /** 动态执行函数 @param func_oid 指定function的Oid @param func_call_str 指定function的调用语句 @param args 指定function的参数列表 @return Datum 运行指定的function后产生的返回值 */ static Datum execute_function(Oid func_oid, const char *func_call_str, List *args) { FunctionCallInfoData fcinfo; /* 存储指定function的元数据,包括函数的调用入口、参数等信息 */ FmgrInfo flinfo; /* 存储结果。即指定function运行后的返回值 */ Datum result; ListCell *lc; int i; char *func_name; char *func_name_copy; List *name_list = NIL; /* 参数检查 */ if (!func_call_str || !args) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid function call parameters"))); /* 初始化函数调用信息和函数调用上下文 */ fmgr_info(func_oid, &flinfo); InitFunctionCallInfoData(fcinfo, &flinfo, flinfo.fn_nargs, InvalidOid, NULL, NULL); /* 解析并设置函数名称用于跟踪 */ func_name_copy = pstrdup(func_call_str); func_name = strtok(func_name_copy, "("); if (!func_name) { pfree(func_name_copy); ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid function call syntax"))); } name_list = stringToQualifiedNameList(func_name); if (name_list == NIL) { pfree(func_name_copy); ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid function name"))); } if (current_function_name) pfree(current_function_name); current_function_name = pstrdup(NameListToString(name_list)); pfree(func_name_copy); /* 设置参数 */ i = 0; foreach(lc, args) { char *arg_str = (char *) lfirst(lc); Datum arg_value; Oid arg_type; Oid input_func; FmgrInfo input_flinfo; if (!arg_str) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid argument value"))); /* 获取参数类型 */ arg_type = get_func_argtype(func_oid, i); if (arg_type == InvalidOid) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid argument type for function"))); /* 获取输入函数 */ input_func = get_type_input_function(arg_type); if (input_func == InvalidOid) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("No input function available for type %s", format_type_be(arg_type)))); /* 转换参数值 */ PG_TRY(); { fmgr_info(input_func, &input_flinfo); arg_value = InputFunctionCall(&input_flinfo, arg_str, arg_type, -1); } PG_CATCH(); { /* 参数转换失败 */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("Invalid input syntax for type %s: %s", format_type_be(arg_type), arg_str))); } PG_END_TRY(); /* 填充参数 */ fcinfo.arg[i] = arg_value; fcinfo.argnull[i] = false; i++; } /* 检查参数数量 */ if (i != flinfo.fn_nargs) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Wrong number of arguments: got %d, expected %d", i, flinfo.fn_nargs))); /* 执行函数 */ PG_TRY(); { result = FunctionCallInvoke(&fcinfo); } PG_CATCH(); { ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("function execution failed"))); } PG_END_TRY(); /* 检查执行结果 */ if (fcinfo.isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), errmsg("Function call failed"))); return result; } /* 函数声明 */ PG_FUNCTION_INFO_V1(pg_trace_tool); /* 函数定义 */ Datum pg_trace_tool(PG_FUNCTION_ARGS) { /* 获取function调用字符串 */ text *funcname = PG_GETARG_TEXT_PP(0); /* 追踪结果 */ char *result; /* 解析出的function的Oid */ Oid func_oid; /* 解析出的function的参数列表 */ List *args = NIL; /* function的调用字符串 */ char *func_call_str; /* 用于存储当前内存上下文呢 */ MemoryContext old_context; /* 参数检查 */ if (!funcname) { ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Function name cannot be NULL"))); } /* 获取函数调用字符串 */ func_call_str = text_to_cstring(funcname); if (!func_call_str) { ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("Invalid function call string"))); } /* 切换到新的内存上下文 */ old_context = MemoryContextSwitchTo(TopMemoryContext); PG_TRY(); { /* 清理之前的跟踪数据 */ cleanup_trace_data(); /* 保存原始钩子 */ prev_ExecutorStart = ExecutorStart_hook; prev_ExecutorRun = ExecutorRun_hook; /* 设置新的钩子 */ ExecutorStart_hook = trace_executor_start; ExecutorRun_hook = trace_executor_run; /* 解析并执行函数 */ func_oid = parse_function_call(func_call_str, &args); execute_function(func_oid, func_call_str, args); list_free_deep(args); result = generate_trace_report(); /* 执行完成,还原原始钩子并清理跟踪数据 */ ExecutorStart_hook = prev_ExecutorStart; ExecutorRun_hook = prev_ExecutorRun; cleanup_trace_data(); if (current_function_name) { pfree(current_function_name); current_function_name = NULL; } /* 切换回原来的内存上下文 */ MemoryContextSwitchTo(old_context); /* 返回跟踪数据,该数据会在数据库控制台打印出来 */ PG_RETURN_CSTRING(result); } PG_CATCH(); { /* 发生错误,清理所有资源并退出 */ if (args != NIL) list_free_deep(args); cleanup_trace_data(); if (current_function_name) { pfree(current_function_name); current_function_name = NULL; } /* 恢复原始钩子 */ ExecutorStart_hook = prev_ExecutorStart; ExecutorRun_hook = prev_ExecutorRun; /* 切换回原来的内存上下文 */ MemoryContextSwitchTo(old_context); PG_RE_THROW(); } PG_END_TRY(); }
2301_80257615/pg_trace_tool
pg_trace_tool.c
C
unknown
16,511
/* * pg_trace_tool.h * * A trace tool for OpenTenBase that can be used to track and analyze the execution of Functions and Procedures. * * Author: CDUESTC Open Atom Open Source Club * Version: 1.0 */
2301_80257615/pg_trace_tool
pg_trace_tool.h
C
unknown
208
package com.jxau.mall.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.controller * @Author: guojiani * @CreateTime: 2025-03-20 20:44 * @Description: TODO * @Version: 1.0 */ @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) //这是一个Spring应用 //@ComponentScan(basePackages = {"com.jxau.mall.demo"}) public class DemoApplication { public static void main(String[] args) { //启动一个Spring 应用 SpringApplication.run(DemoApplication.class,args); } }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/DemoApplication.java
Java
unknown
760
package com.jxau.mall.demo.config; import com.jxau.mall.demo.entity.Dog; import com.jxau.mall.demo.entity.Person; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.config * @Author: guojiani * @CreateTime: 2025-03-29 21:00 * @Description: TODO * @Version: 1.0 */ @Configuration //说明这是一个配置类(容器),可在这里面创建对象 public class ContainerConfig { @Bean //将返回值对象放到容器中 //相当于Dog dog = new Dog(); public Dog dog(){ return new Dog(); } @Bean(value = "p") //相当于Person p = new Person() public Person person(){ return new Person(); } }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/config/ContainerConfig.java
Java
unknown
808
package com.jxau.mall.demo.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.controller * @Author: guojiani * @CreateTime: 2025-03-20 20:54 * @Description: TODO * @Version: 1.0 */ @RestController public class GoodByController { @GetMapping("bye") public String bye(){ return "Goodby SpringBoot!"; } }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/controller/GoodByController.java
Java
unknown
502
package com.jxau.mall.demo.controller; import com.jxau.mall.common.enums.ResponseEnum; import com.jxau.mall.common.util.ResponseVO; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.controller * @Author: guojiani * @CreateTime: 2025-03-20 20:46 * @Description: TODO * @Version: 1.0 */ @RestController //这是一个控制器 public class HelloController { @GetMapping("/hello") //注解: URI public ResponseVO<String> hello(){ String s = "Hello SpringBoot!"; return ResponseVO.success(s); } @GetMapping("/show") public ResponseVO showme(){ return ResponseVO.success("哈哈哈哈哈"); } }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/controller/HelloController.java
Java
unknown
818
package com.jxau.mall.demo.controller; import com.jxau.mall.demo.entity.Person; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.controller * @Author: guojiani * @CreateTime: 2025-03-29 20:14 * @Description: TODO * @Version: 1.0 */ @RestController //PersonController personController = new PersonController(); public class PersonController { @Autowired // 注解:从容器中取 Person 对象 //@Qualifier(value = "p") //指定名字 //@Resource(name="p")//指定名字并从容器中获取对象,相当于上面两个注解 private Person person; @GetMapping("/person") // 映射 URI public String getPerson(){ // person.setName("张三"); // person.setAge(18); return person.toString(); } }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/controller/PersonController.java
Java
unknown
987
package com.jxau.mall.demo.entity; import lombok.Data; import lombok.ToString; import java.util.List; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.entity * @Author: guojiani * @CreateTime: 2025-03-29 20:06 * @Description: TODO * @Version: 1.0 */ @Data @ToString public class Children { private String name;//姓名 private Integer age;//年龄 List<String> love;//爱好 }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/entity/Children.java
Java
unknown
438
package com.jxau.mall.demo.entity; import lombok.Data; import lombok.ToString; import org.springframework.stereotype.Component; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.entity * @Author: guojiani * @CreateTime: 2025-03-29 20:05 * @Description: TODO * @Version: 1.0 */ @Data @ToString @Component public class Dog { private String name;//昵称 private String kind;//品种 }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/entity/Dog.java
Java
unknown
437
package com.jxau.mall.demo.entity; import com.jxau.mall.demo.entity.Children; import com.jxau.mall.demo.entity.Dog; import lombok.Data; import lombok.ToString; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import java.util.Date; import java.util.Map; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.demo.entity * @Author: guojiani * @CreateTime: 2025-03-29 20:12 * @Description: TODO * @Version: 1.0 */ @Data @ToString @Component //在容器中实例化一个对象 相当于Person person = new person(); @ConfigurationProperties(prefix = "person") //读取配置文件,prefix 意思是找以person开头的 public class Person { private String name; // 姓名 private Integer age; // 年龄 private Date birthday; // 生日 private Boolean registied; // 是否注册 private Children child; // 儿子 Map<String, Dog> dogs; // 宠物狗 }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/entity/Person.java
Java
unknown
1,000
package com.jxau.mall.demo.service; import com.jxau.mall.proto.Cart; import java.util.List; /** * @program: shop * @description: 客户端配置 * @author: guojiani * @create: 2025-04-27 15:45 **/ public interface IGrpcClientService { void save(List<Cart> carts) throws Exception; }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/service/IGrpcClientService.java
Java
unknown
310
package com.jxau.mall.demo.service.Impl; import com.jxau.mall.demo.service.IGrpcClientService; import com.jxau.mall.proto.Cart; import com.jxau.mall.proto.RequestParam; import com.jxau.mall.proto.ResponseResult; import com.jxau.mall.proto.RpcSimpleGrpc; import net.devh.boot.grpc.client.inject.GrpcClient; import org.springframework.stereotype.Service; import java.util.List; /** * @program: shop * @description: 接口实现类 * @author: guojiani * @create: 2025-04-27 15:46 **/ @Service public class GrpcClientServiceImpl implements IGrpcClientService { @GrpcClient("sku-grpc") private RpcSimpleGrpc.RpcSimpleBlockingStub simpleBlockingStub ; @Override public void save(List<Cart> carts) throws Exception { // 构建请求参数 RequestParam requestParam = RequestParam.newBuilder().addAllCarts(carts).build(); // 发起RPC调用 ResponseResult result = simpleBlockingStub.dcount(requestParam); // 处理返回结果 if (result.getCode() == 1000){ throw new Exception(result.getMessage()); } } }
2301_80339408/shop2-backend
shop/shop/demo/src/main/java/com/jxau/mall/demo/service/Impl/GrpcClientServiceImpl.java
Java
unknown
1,129
package com.jxau.mall; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; /** * @program: shop * @description:项目启动类 * @author: guojiani * @create: 2025-04-26 15:22 **/ @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class MallCartApplication { public static void main(String[] args) { SpringApplication.run(MallCartApplication.class,args); } }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/MallCartApplication.java
Java
unknown
573
package com.jxau.mall.cart.controller; import com.jxau.mall.cart.entity.Cart; import com.jxau.mall.cart.service.ICartService; import com.jxau.mall.common.util.ResponseVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; import java.util.List; /** * @program: shop * @description: 购物车控制器类 * @author: guojiani * @create: 2025-04-26 16:20 **/ @RestController @RequestMapping(value = "/cart") public class CartController { @Autowired private ICartService cartService; /** * 添加购物车 * id: skuid */ @PostMapping("/save") public ResponseVO add(@RequestBody Cart cart){ // 购物车编号:由用户编号和商品编号组成 String id = cart.getUserId() + cart.getSkuId(); cart.set_id(id); // 创建时间 cart.setCreateTime(LocalDateTime.now()); //加入购物车 cartService.add(cart); return ResponseVO.success(); } /** * 购物车列表 * @return */ @GetMapping(value = "/list/{userId}") public ResponseVO<List<Cart>> list(@PathVariable String userId){ List<Cart> carts = cartService.list(userId); return ResponseVO.success(carts); } @DeleteMapping(value = "/{id}") public ResponseVO delete(@PathVariable String id){ cartService.removeById(id); return ResponseVO.success(); } }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/cart/controller/CartController.java
Java
unknown
1,533
package com.jxau.mall.cart.entity; import lombok.Data; import java.time.LocalDateTime; /** * @program: shop * @description: 购物车实体类 * @author: guojiani * @create: 2025-04-26 15:39 **/ @Data public class Cart { private String _id; // 编号 private String userId; // 用户ID private String name; // 商品名称 private Integer price; // 价格 private String image; // 图片 private String skuId; // 商品ID private Integer num; // 数量 private LocalDateTime createTime; // 创建时间 }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/cart/entity/Cart.java
Java
unknown
570
package com.jxau.mall.cart.mapper; import com.jxau.mall.cart.entity.Cart; import org.springframework.data.mongodb.repository.MongoRepository; /** * @program: shop * @description: 购物车接口 * @author: guojiani * @create: 2025-04-26 15:45 **/ public interface CartMapper extends MongoRepository <Cart,String>{ }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/cart/mapper/CartMapper.java
Java
unknown
336
package com.jxau.mall.cart.service; import com.jxau.mall.cart.entity.Cart; import java.util.List; /** * @program: shop * @description: 购物车业务层接口 * @author: guojiani * @create: 2025-04-26 15:57 **/ public interface ICartService { /** * 加入购物车 * @param cart */ void add(Cart cart); /** * 购物车列表 * @param userId * @return */ List<Cart> list(String userId); /** * 删除购物车 * @param id */ void removeById(String id); /** * 删除多个购物车 * @param ids */ void removeAllById(List<String> ids); }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/cart/service/ICartService.java
Java
unknown
678
package com.jxau.mall.cart.service.impl; import com.jxau.mall.cart.entity.Cart; import com.jxau.mall.cart.mapper.CartMapper; import com.jxau.mall.cart.service.ICartService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import java.util.List; /** * @program: shop * @description: 购物车业务接口实现类 * @author: guojiani * @create: 2025-04-26 16:10 **/ @Service public class CartServiceImpl implements ICartService { @Autowired private CartMapper cartMapper; @Override public void add(Cart cart) { //如果购物车中商品已存在,读取数量,并删除 if(cartMapper.existsById(cart.get_id())){ Cart obj = cartMapper.findById(cart.get_id()).get(); cart.setNum(obj.getNum() + cart.getNum()); cartMapper.deleteById(cart.get_id()); } //增加 cartMapper.save(cart); } @Override public List<Cart> list(String userId) { //查询条件 Cart cart = new Cart(); cart.setUserId(userId); return cartMapper.findAll(Example.of(cart), Sort.by(Sort.Direction.DESC,"createTime")); } @Override public void removeById(String id) { cartMapper.deleteById(id); } public void removeAllById(List<String> ids) { cartMapper.deleteAllById(ids); } }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/cart/service/impl/CartServiceImpl.java
Java
unknown
1,538
package com.jxau.mall.cart.service.impl; import com.jxau.mall.cart.service.ICartService; import com.jxau.mall.proto.Cart; import com.jxau.mall.proto.RequestParam; import com.jxau.mall.proto.ResponseResult; import com.jxau.mall.proto.RpcSimpleGrpc; import io.grpc.stub.StreamObserver; import net.devh.boot.grpc.server.service.GrpcService; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.stream.Collectors; /** * @program: shop * @description: 暴露RPC接口 * @author: guojiani * @create: 2025-04-28 17:39 **/ @GrpcService public class GrpcCartServiceImpl extends RpcSimpleGrpc.RpcSimpleImplBase { @Autowired private ICartService cartService; @Override public void deleteCart(RequestParam request, StreamObserver<ResponseResult> responseObserver) { // 获取参数 List<Cart> cartsList = request.getCartsList(); // 获取购物车Id集合 List<String> ids = cartsList.stream().map(Cart::getId).collect(Collectors.toList()); // 删除购物车 cartService.removeAllById(ids); // 构建返回值 ResponseResult response = ResponseResult.newBuilder() .setCode(2000) .build(); responseObserver.onNext(response); // RPC调用完成 responseObserver.onCompleted(); } }
2301_80339408/shop2-backend
shop/shop/mall-cart/src/main/java/com/jxau/mall/cart/service/impl/GrpcCartServiceImpl.java
Java
unknown
1,408
package com.jxau.mall.generator; import com.baomidou.mybatisplus.generator.FastAutoGenerator; /** * @program: shop * @description: 代码生成器 * @author: guojiani * @create: 2025-04-10 19:45 **/ public class CodeGenerator { public static void main(String[] args) { // 使用 FastAutoGenerator 快速配置代码生成器,注意修改数据库的 URL FastAutoGenerator.create("jdbc:mysql://192.168.100.104:3306/shop_order?serverTimezone=Asia/Shanghai", "root", "051103") // 全局配置 .globalConfig(builder -> { builder.author("guojiani") // 设置作者 .disableOpenDir() // 禁止打开输出目录 .outputDir("mall-order/src/main/java"); // 输出目录,不同项目需要修改 }) // 包配置 .packageConfig(builder -> builder.parent("com.jxau.mall.order") // 设置父包名 .entity("entity") // 设置实体类包名 .mapper("mapper") // 设置 Mapper 接口包名 .service("service") // 设置 Service 接口包名 .serviceImpl("service.impl")//设置 Service 实现类包名 .xml("mappers")//设置 Mapper XML 文件包名 ) // 策略配置 .strategyConfig(builder -> { builder.addInclude("order_info", "order_detail") //设置需要生成的表名 //.addTablePrefix("t_") // 设置过滤表前 .entityBuilder() .enableLombok()// 启用 Lombok .enableTableFieldAnnotation() // 启用字段注解 .controllerBuilder() .enableRestStyle() // 启用 REST 风格 .serviceBuilder() .mapperBuilder(); }) .execute();// 执行生成 } }
2301_80339408/shop2-backend
shop/shop/mall-code-generator/src/main/java/com/jxau/mall/generator/CodeGenerator.java
Java
unknown
2,349
package com.jxau.mall.common.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @program: shop * @description: 允许跨域访问的类 * @author: guojiani * @create: 2025-04-17 14:53 **/ @Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") // 所有接口 .allowCredentials(true) // 是否发送 Cookie .allowedOriginPatterns("*") // 支持域 .allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"}) // 支持方法 .allowedHeaders("*") .exposedHeaders("*"); } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/config/CorsConfig.java
Java
unknown
877
package com.jxau.mall.common.config; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.apache.ibatis.reflection.MetaObject; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.time.LocalDateTime; /** * @program: shop * @description: 自动填充类 * @author: guojiani * @create: 2025-04-10 15:05 **/ @Configuration public class MyBatisPlusConfig { /** * 添加分页插件 * */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // 配置数据,建议单一数据库类型的均设置 dbType。如果配置多个插件, 切记分页最后添加 interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } /** * 创建自动填充配置类实例 */ @Bean public AutoFieldFillHandler autoFieldFillHandler(){ return new AutoFieldFillHandler(); } /** * 自动填充配置类 */ class AutoFieldFillHandler implements MetaObjectHandler { @Override public void insertFill(MetaObject metaObject) { //插入时填充 // 自动填充创建时间字段 createTime是属性名 strictInsertFill(metaObject,"createTime", LocalDateTime.class, LocalDateTime.now()); // 自动填充修改时间字段 strictInsertFill(metaObject,"updateTime", LocalDateTime.class, LocalDateTime.now()); // 自动填充逻辑删除字段 deleted:0 未删除 strictInsertFill(metaObject,"deleted",Integer.class,0); // 自动填充状态:0 正常 strictInsertFill(metaObject,"status",Integer.class,0); } @Override public void updateFill(MetaObject metaObject) { //修改式填充 // 自动填充修改时间字段 strictInsertFill(metaObject,"updateTime", LocalDateTime.class, LocalDateTime.now()); } } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/config/MyBatisPlusConfig.java
Java
unknown
2,421
package com.jxau.mall.common.config; import com.jxau.mall.common.interceptor.AuthorizationInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @program: shop * @description: 注册拦截器工具类 * @author: guojiani * @create: 2025-04-24 21:34 **/ @Configuration public class WebConfig implements WebMvcConfigurer { /** * 注册拦截器,可以注册多个拦截器 * @param registry */ @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new AuthorizationInterceptor()) .addPathPatterns("/**") // 拦截所有地址 .excludePathPatterns("/login","/user/register","/goods/**");// 排除拦截 } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/config/WebConfig.java
Java
unknown
928
package com.jxau.mall.common.enums; import lombok.Getter; /** * 枚举类型类,提前声明状态码 */ @Getter public enum ResponseEnum { /* 成功状态码 */ SUCCESS(2000, "操作成功"), /* 错误状态码 */ FAIL(1000, "操作失败"), /* 参数错误:1001-1999 */ PARAM_IS_INVALID(1001, "参数无效"), PARAM_IS_VALID(1002,"参数检验错误"), PARAM_TYPE_BIND_ERROR(1003, "参数格式错误"), /* 用户错误:2001-2999*/ USER_NOT_LOGGED_IN(2001, "用户未登录,请先登录"), USER_ACCOUNT_FORBIDDEN(2002, "账号不存在或账号已被禁用"), USER_PASSWORD_ERROR(2003, "密码错误"), USER_HAS_EXISTED(2004, "用户已存在"), /* 权限错误:3001-3999 */ PERMISSION_UNAUTHORIZED(3001, "权限不足,无权操作"), PERMISSION_EXPIRE(3002, "登录状态过期!"), PERMISSION_TOKEN_EXPIRED(3003, "token 已过期"); private int code;// 状态码 private String message; // 提示信息 private ResponseEnum(int code, String message) { this.code = code; this.message = message; } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/enums/ResponseEnum.java
Java
unknown
1,258
package com.jxau.mall.common.interceptor; import com.fasterxml.jackson.databind.ObjectMapper; import com.jxau.mall.common.enums.ResponseEnum; import com.jxau.mall.common.util.JwtUtils; import com.jxau.mall.common.util.ResponseVO; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.servlet.HandlerInterceptor; /** * @program: shop * @description: 登录拦截器的工具类 * @author: guojiani * @create: 2025-04-24 21:32 **/ public class AuthorizationInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { //获取请求头中的token String token = request.getHeader("Authorization"); //如果token为空,用户未登录。否则,如果token过期,登录过期,否则通过拦截并存储用户信息 if(token == null){ // 将response输出转换成json格式 ObjectMapper objectMapper = new ObjectMapper(); response.setContentType("application/json;charset=UTF-8"); objectMapper.writeValue(response.getWriter(), ResponseVO.fail(ResponseEnum.USER_NOT_LOGGED_IN)); return false; }else if(JwtUtils.isExpired(token)){ ObjectMapper objectMapper = new ObjectMapper(); response.setContentType("application/json;charset=UTF-8"); objectMapper.writeValue(response.getWriter(), ResponseVO.fail(ResponseEnum.PERMISSION_TOKEN_EXPIRED)); return false; }else { // 获取令牌中的用户信息,在登录时存储了用户的userId Long id = JwtUtils.parseToken(token).get("userId", Long.class); } return true; } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/interceptor/AuthorizationInterceptor.java
Java
unknown
1,862
package com.jxau.mall.common.util; import com.baomidou.mybatisplus.core.toolkit.AES; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.JdbcType; import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; /** * @program: shop * @description: 字段加密和解密处理器 * @author: guojiani * @create: 2025-04-24 21:41 **/ public class EncryptHandler extends BaseTypeHandler<String> { // 密钥(16*N位数),一旦指定不能再修改 private static final String AES_KEY = "BgKLBcLdAgZK7s64"; @Override public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { // 对参数进行加密 if (StringUtils.isEmpty(parameter)) { ps.setString(i, null); }else { // 加密后存入数据库 String encrypt = AES.encrypt(parameter, AES_KEY); ps.setString(i, encrypt); } } @Override public String getNullableResult(ResultSet rs, String columnName) throws SQLException { // 获取结果集的值 String value = rs.getString(columnName); if(StringUtils.isEmpty(value)){ return null; } // 返回解密的值 return AES.decrypt(value,AES_KEY); } @Override public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException { // 获取结果集的值 String value = rs.getString(columnIndex); if(StringUtils.isNotEmpty(value)){ return null; } // 返回解密的值 return AES.decrypt(value,AES_KEY); } @Override public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { // 获取结果集的值 String value = cs.getString(columnIndex); if(StringUtils.isEmpty(value)){ return null; } // 返回解密的值 return AES.decrypt(value,AES_KEY); } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/util/EncryptHandler.java
Java
unknown
2,196
package com.jxau.mall.common.util; /** * @program: shop * @description: 通用加密工具类 * @author: guojiani * @create: 2025-04-24 21:50 **/ public class EncryptUtils { /** * 手机脱敏 * * @param text 明文 * @return 密文 */ public static String hidePhone(String text) { // 显示前三位,后4位,其他隐藏,比如139****9999 // 截取前半段字符 StringBuilder sb = new StringBuilder(text.substring(0, 3)); // 用*号隐藏中间字符 sb.append("*".repeat(text.length() - 7)); // 截取后半段符 sb.append(text.substring(text.length() - 4)); return sb.toString(); } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/util/EncryptUtils.java
Java
unknown
729
package com.jxau.mall.common.util; import com.jxau.mall.common.enums.ResponseEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.web.HttpMediaTypeNotSupportedException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; /** * @program: shop * @description: 统一异常处理的类 * @author: guojiani * @create: 2025-04-17 15:02 **/ @RestControllerAdvice //增强处理:给控制器增加一个功能 @Slf4j // log4j 日志 public class GlobleExceptionHandler { /** * 全局异常处理 * @param e * @return */ @ExceptionHandler(Exception.class) public ResponseVO exception(Exception e){ log.error(e.getMessage(),e);// 打印异常 // 处理异常 return ResponseVO.fail(1000,e.getMessage()); } /** * 参数类型错误 * @param e * @return */ @ExceptionHandler(HttpMediaTypeNotSupportedException.class) public ResponseVO httpMediaTypeNotSupportedException(HttpMediaTypeNotSupportedException e){ log.error(e.getMessage(),e);// 打印异常 // 处理异常 return ResponseVO.fail(ResponseEnum.PARAM_TYPE_BIND_ERROR); } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/util/GlobleExceptionHandler.java
Java
unknown
1,293
package com.jxau.mall.common.util; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * @program: shop * @description: 登录身份验证工具类 * @author: guojiani * @create: 2025-04-24 20:30 **/ public class JwtUtils { // TOKEN的有效期30分钟(单位毫秒) private static final int TOKEN_TIME_OUT = 30 * 60 * 1000 ; // 加密KEY private static final String TOKEN_ENCRY_KEY = "MDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjY"; /** * 生成令牌 * @param claims 私有信息,识别身份 * @return */ public static String generateToken(Map<String,Object> claims){ // 设置头部 Map<String,Object> header = new HashMap<>(); header.put("alg","HS256"); header.put("typ","JWT"); // 签发时间 Long created = System.currentTimeMillis(); Date issued = new Date(created); // 过期时间 long expired = created + TOKEN_TIME_OUT; Date expires = new Date(expired); return Jwts.builder() .setHeader(header) .setClaims(claims) .setExpiration(expires) .setIssuedAt(issued) .signWith(SignatureAlgorithm.HS256,TOKEN_ENCRY_KEY)//设置签名 .compact(); } /** * 解析令牌 * @param token * @return */ public static Claims parseToken(String token) { return Jwts.parser() .setSigningKey(TOKEN_ENCRY_KEY) .parseClaimsJws(token) .getBody(); } /** * 验证令牌 * @param token * @return */ public static boolean isExpired(String token) { if(token == null) return false; try { parseToken(token); return false; } catch (Exception e) { return true; } } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/util/JwtUtils.java
Java
unknown
2,079
package com.jxau.mall.common.util; import com.fasterxml.jackson.annotation.JsonInclude; import com.jxau.mall.common.enums.ResponseEnum; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @program: shop * @description: 视图对象,封装response类,用于统一返回结果,有的也叫DTO * @author: guojiani * @create: 2025-04-16 22:07 **/ @Data @NoArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) // NULL值不显示 public class ResponseVO<T> implements Serializable { private static final long serialVersionUID = 1L; private Integer code;// 操作代码 private String message; // 提示信息 private T data;// 结果数据 public ResponseVO(Integer code, String message) { this.code = code; this.message =message; } /** * 无数据的返回信息 * @param responseEnum */ public ResponseVO(ResponseEnum responseEnum) { this.code = responseEnum.getCode(); this.message = responseEnum.getMessage(); } /** * 带数据的返回信息 * @param responseEnum * @param data */ public ResponseVO(ResponseEnum responseEnum, T data) { this.code = responseEnum.getCode(); this.message = responseEnum.getMessage(); this.data = data; } /** * 成功返回-无数据 * @return */ public static ResponseVO<String> success() { return new ResponseVO<String>(ResponseEnum.SUCCESS); } /** * 成功返回封装-带数据 * @param data * @return * @param <T> */ public static <T> ResponseVO<T> success(T data) { return new ResponseVO<T>(ResponseEnum.SUCCESS, data); } //失败返回封装-使用默认提示信息 public static ResponseVO<String> fail() { return new ResponseVO<String>(ResponseEnum.FAIL); } /** * 失败返回-自定义信息 * @param code * @param message * @return * @param <T> */ public static <T> ResponseVO<T> fail(Integer code,String message) { return new ResponseVO<T>(code, message); } /** * 失败返回 * @param responseEnum * @return */ public static ResponseVO<String> fail(ResponseEnum responseEnum) { return new ResponseVO<String>(responseEnum); } /** * 失败返回-带数据 * @param responseEnum * @param data * @return * @param <T> */ public static <T> ResponseVO<T> fail(ResponseEnum responseEnum,T data) { return new ResponseVO<T>(responseEnum, data); } }
2301_80339408/shop2-backend
shop/shop/mall-common/src/main/java/com/jxau/mall/common/util/ResponseVO.java
Java
unknown
2,721
package com.jxau.mall; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @program: shop * @description: 该项目的启动类,也叫主程序 * @author: guojiani * @create: 2025-04-10 22:39 **/ @SpringBootApplication @MapperScan(basePackages = {"com.jxau.mall.goods.mapper"}) public class MallGoodsApplication { public static void main(String[] args) { SpringApplication.run(MallGoodsApplication.class,args); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/MallGoodsApplication.java
Java
unknown
580
package com.jxau.mall.goods.controller; import com.jxau.mall.common.util.ResponseVO; import com.jxau.mall.goods.entity.Brand; import com.jxau.mall.goods.service.IBrandService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * <p> * 品牌表 前端控制器 * </p> * * @author guojiani * @since 2025-04-10 */ @RestController @RequestMapping("/goods/brand") public class BrandController { // @Autowired // private IBrandService brandService; @Autowired private IBrandService brandService; /** * 查询所有品牌 * @return */ @GetMapping("/list") public ResponseVO<List<Brand>> list(){ // List<Brand> brands = brandService.list(); List<Brand> brands = brandService.list(); return ResponseVO.success(brands); } /** * 按一级分类ID查询 * @param id * @return */ @GetMapping("/category/1/{id}") public ResponseVO<List<Brand>> listByOneCategoryId(@PathVariable Integer id){ List<Brand> brands = brandService.listByOneCategoryId(id); return ResponseVO.success(brands); } /** * 按二级分类ID查询 * @param id * @return */ @GetMapping("/category/2/{id}") public ResponseVO<List<Brand>> listByTwoCategoryId(@PathVariable Integer id){ List<Brand> brands = brandService.listByTwoCategoryId(id); return ResponseVO.success(brands); } /** * 按三级分类ID查询 * @param id * @return */ @GetMapping("/category/3/{id}") public ResponseVO<List<Brand>> listByThreeCategoryId(@PathVariable Integer id){ List<Brand> brands = brandService.listByThreeCategoryId(id); return ResponseVO.success(brands); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/controller/BrandController.java
Java
unknown
2,092
package com.jxau.mall.goods.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * <p> * 前端控制器 * </p> * * @author guojiani * @since 2025-04-10 */ @RestController @RequestMapping("/categoryBrand") public class CategoryBrandController { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/controller/CategoryBrandController.java
Java
unknown
365
package com.jxau.mall.goods.controller; import com.jxau.mall.common.util.ResponseVO; import com.jxau.mall.goods.model.CategoryDTO; import com.jxau.mall.goods.service.ICategoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * <p> * 商品类目 前端控制器 * </p> * * @author guojiani * @since 2025-04-10 */ @RestController @RequestMapping("/goods/category") public class CategoryController { @Autowired private ICategoryService categoryService; @GetMapping("/list") public ResponseVO list(){ //获取响应数据 List<CategoryDTO> list = categoryService.listAll(); //响应数据 return ResponseVO.success(list); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/controller/CategoryController.java
Java
unknown
954
package com.jxau.mall.goods.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.jxau.mall.common.util.ResponseVO; import com.jxau.mall.goods.model.Product; import com.jxau.mall.goods.service.IProductService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @program: shop * @description: 商品展示控制器 * @author: guojiani * @create: 2025-04-20 22:55 **/ @RestController @RequestMapping("/goods/product") public class ProductController { @Autowired private IProductService productService; @GetMapping("/list") public ResponseVO page(Product product){ IPage page = productService.page(product); return ResponseVO.success(page); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/controller/ProductController.java
Java
unknown
938
package com.jxau.mall.goods.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * <p> * 商品表 前端控制器 * </p> * * @author guojiani * @since 2025-04-10 */ @RestController @RequestMapping("/skuInfo") public class SkuInfoController { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/controller/SkuInfoController.java
Java
unknown
362
package com.jxau.mall.goods.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** * <p> * 品牌表 * </p> * * @author guojiani * @since 2025-04-10 */ @Getter @Setter @TableName("brand") @ToString public class Brand implements Serializable { private static final long serialVersionUID = 1L; /** * 品牌id */ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 品牌名称 */ @TableField("name") private String name; /** * 品牌logo */ @TableField("logo") private String logo; /** * 品牌图片地址 */ @TableField("image") private String image; /** * 品牌的首字母 */ @TableField("initial") private String initial; /** * 排序 */ @TableField("sort") private Integer sort; }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/entity/Brand.java
Java
unknown
1,186
package com.jxau.mall.goods.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** * <p> * 商品类目 * </p> * * @author guojiani * @since 2025-04-10 */ @Getter @Setter @TableName("category") @ToString public class Category implements Serializable { private static final long serialVersionUID = 1L; /** * 分类ID */ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 分类名称 */ @TableField("name") private String name; /** * 上级ID */ @TableField("parent_id") private Integer parentId; }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/entity/Category.java
Java
unknown
912
package com.jxau.mall.goods.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** * <p> * * </p> * * @author guojiani * @since 2025-04-10 */ @Getter @Setter @TableName("category_brand") @ToString public class CategoryBrand implements Serializable { private static final long serialVersionUID = 1L; /** * 分类ID */ // 表里面允许有多个主键,但实体类类里面不允许// 未标记主键 @TableId(value = "categoryId", type = IdType.AUTO) private Integer categoryId; /** * 品牌ID */ private Integer brandId; }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/entity/CategoryBrand.java
Java
unknown
839
package com.jxau.mall.goods.entity; import com.baomidou.mybatisplus.annotation.*; import java.io.Serializable; import java.time.LocalDateTime; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** * <p> * 商品表 * </p> * * @author guojiani * @since 2025-04-10 */ @Getter @Setter @TableName("sku_info") @ToString public class SkuInfo implements Serializable { private static final long serialVersionUID = 1L; /** * 商品id */ @TableId(value = "id",type = IdType.ASSIGN_ID) private Long id; /** * SPUID */ @TableField("spu_id") private Long spuId; /** * 价格 */ @TableField("price") private Long price; /** * sku名称 */ @TableField("sku_name") private String skuName; /** * 商品规格描述 */ @TableField("sku_attribute") private String skuAttribute; /** * 数量 */ @TableField("num") private Integer num; /** * 品牌 */ @TableField("brand_id") private Long brandId; /** * 品牌名称 */ @TableField("brand_name") private String brandName; /** * 分类id */ @TableField("category_id") private Long categoryId; /** * 分类名称 */ @TableField("category_name") private String categoryName; /** * 商品图片 */ @TableField("sku_default_img") private String skuDefaultImg; /** * 商品图片列表 */ @TableField("images") private String images; /** * 商品状态(1:已下架 0:正常) */ @TableField(value = "status",fill = FieldFill.INSERT) private Integer status; /** * 创建时间 */ @TableField(value = "create_time",fill = FieldFill.INSERT) private LocalDateTime createTime; /** * 更新时间 */ @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; /** * 商品状态(1:已删除 0:正常) */ @TableField(value = "deleted",fill = FieldFill.INSERT) @TableLogic //标记该字段为逻辑删除的字段,yml文件中也需要指定 private Integer deleted; }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/entity/SkuInfo.java
Java
unknown
2,373
package com.jxau.mall.goods.mapper; import com.jxau.mall.goods.entity.Brand; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** * <p> * 品牌表 Mapper 接口 * </p> * * @author guojiani * @since 2025-04-10 */ @Mapper public interface BrandMapper extends BaseMapper<Brand> { /** * 按一级分类 ID 查询品牌 * @param id * @return */ List<Brand> selectByOneCategoryId(int id); /** * 按二级分类 ID 查询品牌 * @param id * @return */ List<Brand> selectByTwoCategoryId(int id); /** * 按三级级分类 ID 查询品牌 * @param id * @return */ List<Brand> selectByThreeCategoryId(int id); }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/mapper/BrandMapper.java
Java
unknown
809
package com.jxau.mall.goods.mapper; import com.jxau.mall.goods.entity.CategoryBrand; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * Mapper 接口 * </p> * * @author guojiani * @since 2025-04-10 */ public interface CategoryBrandMapper extends BaseMapper<CategoryBrand> { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/mapper/CategoryBrandMapper.java
Java
unknown
320
package com.jxau.mall.goods.mapper; import com.jxau.mall.goods.entity.Category; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 商品类目 Mapper 接口 * </p> * * @author guojiani * @since 2025-04-10 */ public interface CategoryMapper extends BaseMapper<Category> { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/mapper/CategoryMapper.java
Java
unknown
317
package com.jxau.mall.goods.mapper; import com.jxau.mall.goods.entity.SkuInfo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 商品表 Mapper 接口 * </p> * * @author guojiani * @since 2025-04-10 */ public interface SkuInfoMapper extends BaseMapper<SkuInfo> { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/mapper/SkuInfoMapper.java
Java
unknown
311
package com.jxau.mall.goods.model; import com.jxau.mall.goods.entity.Category; import lombok.Data; import java.io.Serializable; import java.util.List; /** * @program: shop * @description: 业务类,用来封装业务层的数据 * @author: guojiani * @create: 2025-04-15 11:08 **/ @Data public class CategoryDTO extends Category implements Serializable { //继承了category实体类就不需要写属性名 // private Long id; // private String name; private static final long serialVersionUID = 1L; List<CategoryDTO> categoryList; //自关联表的设计 }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/model/CategoryDTO.java
Java
unknown
615
package com.jxau.mall.goods.model; import com.jxau.mall.goods.entity.SkuInfo; import lombok.Data; /** * @program: shop * @description: 封装实现商品展示的类 * @author: guojiani * @create: 2025-04-19 21:27 **/ @Data public class Product extends SkuInfo { private Integer oneCategoryId; // 一级分类 ID private Integer twoCategoryId; // 二级分类 ID private Integer current; // 当前页 private Integer size; // 页面大小 }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/model/Product.java
Java
unknown
482
package com.jxau.mall.goods.model; import lombok.Data; /** * @program: shop * @description: 商品模块实现库存修改 * @author: guojiani * @create: 2025-04-27 15:16 **/ @Data public class Stock { private Long skuId; // 库存Id private Integer num; // 数量 }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/model/Stock.java
Java
unknown
295
package com.jxau.mall.goods.service; import com.jxau.mall.goods.entity.Brand; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** * <p> * 品牌表 服务类 * </p> * * @author guojiani * @since 2025-04-10 */ public interface IBrandService extends IService<Brand> { /** * 按一级分类ID查询 * @param id * @return */ List<Brand> listByOneCategoryId(int id); /** * 按三级分类ID查询 * @param id * @return */ List<Brand> listByTwoCategoryId(int id); /** * 按二级分类ID查询 * @param id * @return */ List<Brand> listByThreeCategoryId(int id); }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/IBrandService.java
Java
unknown
724
package com.jxau.mall.goods.service; import com.jxau.mall.goods.entity.CategoryBrand; import com.baomidou.mybatisplus.extension.service.IService; /** * <p> * 服务类 * </p> * * @author guojiani * @since 2025-04-10 */ public interface ICategoryBrandService extends IService<CategoryBrand> { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/ICategoryBrandService.java
Java
unknown
321
package com.jxau.mall.goods.service; import com.jxau.mall.goods.entity.Category; import com.baomidou.mybatisplus.extension.service.IService; import com.jxau.mall.goods.model.CategoryDTO; import java.util.List; /** * <p> * 商品类目 服务类 * </p> * * @author guojiani * @since 2025-04-10 */ public interface ICategoryService extends IService<Category> { /** * 查询所有的类别 */ List<CategoryDTO> listAll(); }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/ICategoryService.java
Java
unknown
471
package com.jxau.mall.goods.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.jxau.mall.goods.model.Product; /** * @program: shop * @description: 实现商品展示方法的接口 * @author: guojiani * @create: 2025-04-20 21:34 **/ public interface IProductService { /** * 查询商品 * @param product * @return */ IPage page(Product product); }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/IProductService.java
Java
unknown
424
package com.jxau.mall.goods.service; import com.jxau.mall.goods.entity.SkuInfo; import com.baomidou.mybatisplus.extension.service.IService; import com.jxau.mall.goods.model.Stock; import java.util.List; /** * <p> * 商品表 服务类 * </p> * * @author guojiani * @since 2025-04-10 */ public interface ISkuInfoService extends IService<SkuInfo> { /** * 库存递减 * @param stocks * @throws Exception */ void dcount(List<Stock> stocks) throws Exception; }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/ISkuInfoService.java
Java
unknown
519
package com.jxau.mall.goods.service.impl; import com.jxau.mall.goods.entity.Brand; import com.jxau.mall.goods.mapper.BrandMapper; import com.jxau.mall.goods.service.IBrandService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 品牌表 服务实现类 * </p> * * @author guojiani * @since 2025-04-10 */ @Service public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements IBrandService { @Override public List<Brand> listByOneCategoryId(int id) { return baseMapper.selectByOneCategoryId(id); } @Override public List<Brand> listByTwoCategoryId(int id) { return baseMapper.selectByTwoCategoryId(id); } @Override public List<Brand> listByThreeCategoryId(int id) { return baseMapper.selectByThreeCategoryId(id); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/impl/BrandServiceImpl.java
Java
unknown
950
package com.jxau.mall.goods.service.impl; import com.jxau.mall.goods.entity.CategoryBrand; import com.jxau.mall.goods.mapper.CategoryBrandMapper; import com.jxau.mall.goods.service.ICategoryBrandService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; /** * <p> * 服务实现类 * </p> * * @author guojiani * @since 2025-04-10 */ @Service public class CategoryBrandServiceImpl extends ServiceImpl<CategoryBrandMapper, CategoryBrand> implements ICategoryBrandService { }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/impl/CategoryBrandServiceImpl.java
Java
unknown
569
package com.jxau.mall.goods.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.jxau.mall.goods.entity.Category; import com.jxau.mall.goods.mapper.CategoryMapper; import com.jxau.mall.goods.model.CategoryDTO; import com.jxau.mall.goods.service.ICategoryService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.util.List; import java.util.stream.Collectors; /** * <p> * 商品类目 服务实现类 * 查询所有的表,包括一级类别,二级类别.... * </p> * * @author guojiani * @since 2025-04-10 */ @Service public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService { @Override public List<CategoryDTO> listAll() { //条件构造器 LambdaQueryChainWrapper<Category> queryOne = new LambdaQueryChainWrapper<>(baseMapper); // 1 查询一级分类 List<Category> ones = queryOne.isNull(Category::getParentId).list(); // 2 查询二级 List<CategoryDTO> oneDTOs = ones.stream().map(one -> { //条件构造器 LambdaQueryChainWrapper<Category> queryTwo = new LambdaQueryChainWrapper<>(baseMapper); // 2.1 把一级分类转换成 DTO CategoryDTO oneDTO = JSON.parseObject(JSON.toJSONString(one), CategoryDTO.class); // 2.2 查询二级分类 List<Category> twos = queryTwo.eq(Category::getParentId, oneDTO.getId()).list(); // 3 查询三级 List<CategoryDTO> twoDTOs = twos.stream().map(two -> { //条件构造器 LambdaQueryChainWrapper<Category> queryThree = new LambdaQueryChainWrapper<>(baseMapper); // 3.1 把二级分类转换成 DTO CategoryDTO twoDTO = JSON.parseObject(JSON.toJSONString(two), CategoryDTO.class); // 3.2 查询三级分类 List<Category> threes = queryThree.eq(Category::getParentId, twoDTO.getId()).list(); // 3.3 转换成 DTO List<CategoryDTO> threeDTOs = threes.stream().map(three -> JSON.parseObject(JSON.toJSONString(three), CategoryDTO.class)) .collect(Collectors.toList()); // 3.4 封装三级分类 twoDTO.setCategoryList(threeDTOs); return twoDTO; }).collect(Collectors.toList()); // 把二级分类转换成 DTO // 将二级分类封装到 oneDTO.setCategoryList(twoDTOs); return oneDTO; }).collect(Collectors.toList()); return oneDTOs; } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/impl/CategoryServiceImpl.java
Java
unknown
2,980
package com.jxau.mall.goods.service.impl; import com.alibaba.fastjson.JSON; import com.jxau.mall.goods.model.Stock; import com.jxau.mall.goods.service.ISkuInfoService; import com.jxau.mall.proto.Cart; import com.jxau.mall.proto.RequestParam; import com.jxau.mall.proto.ResponseResult; import com.jxau.mall.proto.RpcSimpleGrpc; import io.grpc.stub.StreamObserver; import net.devh.boot.grpc.server.service.GrpcService; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.stream.Collectors; /** * @program: shop * @description: 暴露RPC接口 * @author: guojiani * @create: 2025-04-27 15:23 **/ @GrpcService public class GrpcSkuInfoServiceImpl extends RpcSimpleGrpc.RpcSimpleImplBase { @Autowired private ISkuInfoService skuInfoService; @Override public void dcount(RequestParam request, StreamObserver<ResponseResult> responseObserver) { // 提取请求参数 List<Cart> cartsList = request.getCartsList(); // 将proto类Cart对象转换成Stock对象 List<Stock> stocks = cartsList.stream().map(e -> JSON.parseObject(JSON.toJSONString(e), Stock.class)) .collect(Collectors.toList()); /* * 调用库存修改方法,对库存进行修改,并封装响应数据 */ try { skuInfoService.dcount(stocks); // 构建返回值 ResponseResult response = ResponseResult.newBuilder() .setCode(2000) .build(); // 填入返回内容 responseObserver.onNext(response); } catch (Exception e) { ResponseResult response = ResponseResult.newBuilder() .setCode(1000) .setMessage(e.getMessage()) .build(); responseObserver.onNext(response); } // gRPC服务完成 responseObserver.onCompleted(); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/impl/GrpcSkuInfoServiceImpl.java
Java
unknown
2,018
package com.jxau.mall.goods.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.jxau.mall.goods.entity.Category; import com.jxau.mall.goods.entity.SkuInfo; import com.jxau.mall.goods.mapper.CategoryMapper; import com.jxau.mall.goods.mapper.SkuInfoMapper; import com.jxau.mall.goods.model.Product; import com.jxau.mall.goods.service.IProductService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.stream.Collectors; /** * @program: shop * @description: IProductService实现类,用于写具体的实现方法 * @author: guojiani * @create: 2025-04-20 21:41 **/ @Service public class ProductServiceImpl implements IProductService { @Autowired private SkuInfoMapper skuInfoMapper; @Autowired private CategoryMapper categoryMapper; @Override public IPage page(Product product) { //创建条件构造器 LambdaQueryChainWrapper<SkuInfo> skuWrapper = new LambdaQueryChainWrapper<>(skuInfoMapper); /* * 按商品类别查询 * 如果三级类别不为空,按三级类别查询 * 否则,如果二级类别不为空,按二级类别查询 * 否则,如果一级类别不为空,按一级类别查询 */ //如果三级类别不为空,按三级类别查询 if (product.getCategoryId() != null) { skuWrapper.eq(SkuInfo::getCategoryId, product.getCategoryId()); //相当于SkuInfo::getCategoryId等于product.getCategoryId() } //否则,如果二级类别不为空,按二级类别查询 else if (product.getTwoCategoryId() != null) { //1构造查询条件 //1.1查询三级类别 LambdaQueryChainWrapper<Category> categoryWrapper = new LambdaQueryChainWrapper<>(categoryMapper); List<Category> list = categoryWrapper.eq(Category::getParentId, product.getTwoCategoryId()) .select(Category::getId) .list(); //1.2提取ID(将以上list集合中的id(该id为三级id)提取出来单独放到一个集合中) List<Integer> ids = list.stream().map(Category::getId).collect(Collectors.toList()); //2.构建商品查询条件 skuWrapper.in(SkuInfo::getCategoryId, ids); } //否则,如果一级类别不为空,按一级类别查询 else if (product.getOneCategoryId() != null) { // 1 查询一级类别下的所有二级类别 // 分类查询条件构建器 LambdaQueryChainWrapper<Category> oneWrapper = new LambdaQueryChainWrapper<>(categoryMapper); List<Category> ones = oneWrapper.eq(Category::getParentId,product.getOneCategoryId()) .select(Category::getId).list(); // 提取类别 ID List<Integer> oneIds = ones.stream().map(Category::getId).collect(Collectors.toList()); // 2 查询二级类别下的所有三级类别 // 重建查询条件构造器 LambdaQueryChainWrapper<Category> twoWrapper = new LambdaQueryChainWrapper<>(categoryMapper); List<Category> list = twoWrapper.in(Category::getParentId, oneIds) .select(Category::getId).list(); // 提取类别 ID List<Integer> ids = list.stream().map(Category::getId).collect(Collectors.toList()); // 3 构建查询条件 skuWrapper.in(SkuInfo::getCategoryId,ids); } //按品牌查询 if(product.getBrandId() !=null){ skuWrapper.eq(SkuInfo::getBrandId, product.getBrandId()); } //按品名查询 if(product.getBrandName() !=null){ skuWrapper.like(SkuInfo::getSkuName, product.getBrandName()); } //选择列,也就是选择需要返回的列名 skuWrapper.select(SkuInfo::getId,SkuInfo::getSkuName,SkuInfo::getPrice,SkuInfo::getSkuDefaultImg); //分页 Page page = new Page(); if (product.getCurrent() !=null && product.getSize()!=0) { // page = new Page(product.getCurrent(), product.getSize()); // 或者用上面那种方法 page.setCurrent(product.getCurrent()); page.setSize(product.getSize()); } return skuWrapper.page(page); } }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/impl/ProductServiceImpl.java
Java
unknown
4,836
package com.jxau.mall.goods.service.impl; import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.jxau.mall.goods.entity.SkuInfo; import com.jxau.mall.goods.mapper.SkuInfoMapper; import com.jxau.mall.goods.model.Stock; import com.jxau.mall.goods.service.ISkuInfoService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 商品表 服务实现类 * </p> * * @author guojiani * @since 2025-04-10 */ @Service public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoMapper, SkuInfo> implements ISkuInfoService { @Override public void dcount(List<Stock> stocks) throws Exception { /* * 遍历购物车数据 * 如果找到库存商品,计算库存剩余量 * 如果库存剩余量>=0,修改库存,否则抛出异常 */ for (Stock stock : stocks) { SkuInfo skuInfo = baseMapper.selectById(stock.getSkuId()); if(skuInfo != null){ int margin = skuInfo.getNum() - stock.getNum(); if(margin >= 0){ // 条件构造器 LambdaUpdateChainWrapper<SkuInfo> updateChainWrapper = new LambdaUpdateChainWrapper<>(baseMapper); // 只修改num字段的值 updateChainWrapper.eq(SkuInfo::getId,skuInfo.getId()) .set(SkuInfo::getNum,margin).update(); }else { throw new Exception("库存不足"); } } } } // @Autowired //问:业务层如何调用DAO层? 答:通过依赖注入/控制反转 // private SkuInfoMapper skuInfoMapper;//因为在父类里面注入对象,这句话就可以不写 // private SkuInfoMapper baseMapper;//因为在父类里面的话为这句,变量名为baseMapper }
2301_80339408/shop2-backend
shop/shop/mall-goods/src/main/java/com/jxau/mall/goods/service/impl/SkuInfoServiceImpl.java
Java
unknown
2,075
package com.jxau.mall; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @MapperScan(basePackages = {"com.jxau.mall.order.mapper"}) public class MallOrderApplication { public static void main(String[] args) { SpringApplication.run(MallOrderApplication.class, args); } }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/MallOrderApplication.java
Java
unknown
439
package com.jxau.mall.order.controller; import com.jxau.mall.common.util.ResponseVO; import com.jxau.mall.order.model.OrderVO; import com.jxau.mall.order.service.IOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * <p> * 订单表 前端控制器 * </p> * * @author guojiani * @since 2025-04-28 */ @RestController @RequestMapping("/order") public class OrderController { @Autowired private IOrderService orderService; @PostMapping("/save") public ResponseVO save(@RequestBody OrderVO orderVO) throws Exception { orderService.save(orderVO); return ResponseVO.success(); }}
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/controller/OrderController.java
Java
unknown
923
package com.jxau.mall.order.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * <p> * 订单中所包含的商品 前端控制器 * </p> * * @author guojiani * @since 2025-04-28 */ @RestController @RequestMapping("/orderDetail") public class OrderDetailController { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/controller/OrderDetailController.java
Java
unknown
388
package com.jxau.mall.order.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.math.BigDecimal; import lombok.Getter; import lombok.Setter; /** * <p> * 订单中所包含的商品 * </p> * * @author guojiani * @since 2025-04-28 */ @Getter @Setter @TableName("order_detail") public class OrderDetail implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 订单id */ @TableField("order_id") private String orderId; /** * 销售价格 */ @TableField("price") private BigDecimal price; /** * 购买数量 */ @TableField("quantity") private Integer quantity; /** * 商品SKU_ID */ @TableField("sku_id") private Long skuId; /** * 商品名称 */ @TableField("sku_name") private String skuName; /** * 图片地址 */ @TableField("image") private String image; /** * 金额合计 */ @TableField("amount") private BigDecimal amount; }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/entity/OrderDetail.java
Java
unknown
1,380
package com.jxau.mall.order.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDateTime; import lombok.Getter; import lombok.Setter; /** * <p> * 订单表 * </p> * * @author guojiani * @since 2025-04-28 */ @Getter @Setter @TableName("order_info") public class OrderInfo implements Serializable { private static final long serialVersionUID = 1L; /** * 订单编号 */ @TableId("order_id") private String orderId; /** * 提交时间 */ @TableField("create_time") private LocalDateTime createTime; /** * 用户帐号 */ @TableField("user_id") private Long userId; /** * 订单总金额 */ @TableField("total_amount") private BigDecimal totalAmount; /** * 支付方式:0->未支付;1->支付宝;2->微信 */ @TableField("pay_type") private Integer payType; /** * 订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单 */ @TableField("status") private Integer status; /** * 订单类型:0->正常订单;1->秒杀订单 */ @TableField("order_type") private Integer orderType; /** * 收货人 */ @TableField("recipients") private String recipients; /** * 收货人手机 */ @TableField("recipients_mobile") private String recipientsMobile; /** * 收货人地址 */ @TableField("recipients_address") private String recipientsAddress; /** * 交易流水号 */ @TableField("transaction_id") private String transactionId; /** * 确认收货状态:0->未确认;1->已确认 */ @TableField("confirm_status") private Integer confirmStatus; /** * 删除状态:0->未删除;1->已删除 */ @TableField("deleted") private Integer deleted; /** * 支付时间 */ @TableField("payment_time") private LocalDateTime paymentTime; /** * 发货时间 */ @TableField("delivery_time") private LocalDateTime deliveryTime; /** * 确认收货时间 */ @TableField("receive_time") private LocalDateTime receiveTime; /** * 修改时间 */ @TableField("update_time") private LocalDateTime updateTime; }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/entity/OrderInfo.java
Java
unknown
2,672
package com.jxau.mall.order.mapper; import com.jxau.mall.order.entity.OrderDetail; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 订单中所包含的商品 Mapper 接口 * </p> * * @author guojiani * @since 2025-04-28 */ public interface OrderDetailMapper extends BaseMapper<OrderDetail> { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/mapper/OrderDetailMapper.java
Java
unknown
341
package com.jxau.mall.order.mapper; import com.jxau.mall.order.entity.OrderInfo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 订单表 Mapper 接口 * </p> * * @author guojiani * @since 2025-04-28 */ public interface OrderInfoMapper extends BaseMapper<OrderInfo> { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/mapper/OrderInfoMapper.java
Java
unknown
317
package com.jxau.mall.order.model; /** * @program: shop * @description: 封装前端传递过来的订单数据 * @author: guojiani * @create: 2025-04-28 19:32 **/ import com.jxau.mall.order.entity.OrderDetail; import com.jxau.mall.order.entity.OrderInfo; import lombok.Data; import java.io.Serializable; import java.util.List; @Data public class OrderVO extends OrderInfo implements Serializable { private static final long serialVersionUID = 1L; List<OrderDetail> orderDetails;// 订单详情集合 private List<String> cartIds; // 购物车Id集合 }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/model/OrderVO.java
Java
unknown
597
package com.jxau.mall.order.service; import com.jxau.mall.order.entity.OrderDetail; import com.baomidou.mybatisplus.extension.service.IService; /** * <p> * 订单中所包含的商品 服务类 * </p> * * @author guojiani * @since 2025-04-28 */ public interface IOrderDetailService extends IService<OrderDetail> { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/service/IOrderDetailService.java
Java
unknown
342
package com.jxau.mall.order.service; import com.baomidou.mybatisplus.extension.service.IService; import com.jxau.mall.order.entity.OrderDetail; import com.jxau.mall.order.entity.OrderInfo; /** * @program: shop * * @description: * * @author: guojiani * * @create: 2025-04-29 12:25 **/ public interface IOrderInfoService extends IService<OrderInfo> { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/service/IOrderInfoService.java
Java
unknown
371
package com.jxau.mall.order.service; import com.jxau.mall.order.entity.OrderInfo; import com.baomidou.mybatisplus.extension.service.IService; import com.jxau.mall.order.model.OrderVO; /** * <p> * 订单表 服务类 * </p> * * @author guojiani * @since 2025-04-28 */ public interface IOrderService { /** * 生成订单 * @param orderVO * @throws Exception */ void save(OrderVO orderVO) throws Exception; }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/service/IOrderService.java
Java
unknown
465
package com.jxau.mall.order.service.impl; import com.jxau.mall.order.entity.OrderDetail; import com.jxau.mall.order.mapper.OrderDetailMapper; import com.jxau.mall.order.service.IOrderDetailService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; /** * <p> * 订单中所包含的商品 服务实现类 * </p> * * @author guojiani * @since 2025-04-28 */ @Service public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements IOrderDetailService { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/service/impl/OrderDetailServiceImpl.java
Java
unknown
582
package com.jxau.mall.order.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jxau.mall.order.entity.OrderDetail; import com.jxau.mall.order.entity.OrderInfo; import com.jxau.mall.order.mapper.OrderDetailMapper; import com.jxau.mall.order.mapper.OrderInfoMapper; import com.jxau.mall.order.service.IOrderInfoService; import org.springframework.stereotype.Service; @Service public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService { }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/service/impl/OrderInfoServiceImpl.java
Java
unknown
552
package com.jxau.mall.order.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.jxau.mall.order.entity.OrderDetail; import com.jxau.mall.order.entity.OrderInfo; import com.jxau.mall.order.model.OrderVO; import com.jxau.mall.order.service.IOrderDetailService; import com.jxau.mall.order.service.IOrderInfoService; import com.jxau.mall.order.service.IOrderService; import com.jxau.mall.proto.Cart; import com.jxau.mall.proto.RequestParam; import com.jxau.mall.proto.ResponseResult; import com.jxau.mall.proto.RpcSimpleGrpc; import net.devh.boot.grpc.client.inject.GrpcClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.List; import java.util.stream.Collectors; @Service public class OrderServiceImpl implements IOrderService { @GrpcClient("sku-grpc") private RpcSimpleGrpc.RpcSimpleBlockingStub skuStub ; @GrpcClient("cart-grpc") private RpcSimpleGrpc.RpcSimpleBlockingStub cartStub ; @Autowired private IOrderInfoService orderInfoService; @Autowired private IOrderDetailService orderDetailService; @Override public void save(OrderVO orderVO) throws Exception { // 生成订单编号 String orderId = IdWorker.getIdStr(); // 分解参数 List<OrderDetail> orderDetails = orderVO.getOrderDetails(); List<String> cartIds = orderVO.getCartIds(); // 1 保存订单详情 // 1.1 设置各商品的订单编号和合计金额 List<OrderDetail> details = orderDetails.stream().map(e -> { e.setOrderId(orderId);// 设置订单 // 设置合计金额 BigDecimal amount = e.getPrice().multiply(new BigDecimal(e.getQuantity())); e.setAmount(amount); return e; }).collect(Collectors.toList()); // 1.2 保存订单详情 orderDetailService.saveBatch(details); // 2 保存订单 // 2.1 计算订单总金额 BigDecimal totalAmount = new BigDecimal(0); for (OrderDetail detail : details) { totalAmount = totalAmount.add(detail.getAmount()); } // 2.2 创建订单对象 OrderInfo orderInfo = JSON.parseObject(JSON.toJSONString(orderVO),OrderInfo.class); // 2.3 保存订单 orderInfoService.save(orderInfo); // 3 递减库存 // 3.1 构建购物车集合 List<Cart> carts = details.stream().map(e -> { Cart cart = Cart.newBuilder() .setSkuId(e.getSkuId()) .setNum(e.getQuantity()) .build(); return cart; }).collect(Collectors.toList()); // 3.2 递减库存-远程调用 RequestParam skuParam = RequestParam.newBuilder().addAllCarts(carts).build(); ResponseResult result = skuStub.dcount(skuParam); if (result.getCode() == 1000) { throw new Exception(result.getMessage()); } // 4 删除购物车 // 4.1 构建购物车集合 List<Cart> cartList = cartIds.stream().map(id -> { Cart cart = Cart.newBuilder().setId(id).build(); return cart; }).collect(Collectors.toList()); // 4.2 删除购物车-远程调用 RequestParam cartParam = RequestParam.newBuilder().addAllCarts(cartList).build(); cartStub.deleteCart(cartParam); } }
2301_80339408/shop2-backend
shop/shop/mall-order/src/main/java/com/jxau/mall/order/service/impl/OrderServiceImpl.java
Java
unknown
3,593
package com.jxau.mall; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; /** * @BelongsProject: shop * @Belongspackage: com.jxau.mall.user * @Author: guojiani * @CreateTime: 2025-03-30 00:53 * @Description: TODO * @Version: 1.0 */ @SpringBootApplication @MapperScan(basePackages = {"com.jxau.mall.user.mapper"}) //把接口的实现类都装到容器中去 //@ComponentScan(basePackages = {"com.jxau.mall.common.config","com.jxau.mall.user//还有一种解决方法为将该类移动到mall子目录下,这里用的是第二种方法 public class MallUserApplication { public static void main(String[] args) { SpringApplication.run(MallUserApplication.class,args); } }
2301_80339408/shop2-backend
shop/shop/mall-user/src/main/java/com/jxau/mall/MallUserApplication.java
Java
unknown
901
package com.jxau.mall.user.controller; import com.jxau.mall.common.util.ResponseVO; import com.jxau.mall.user.entity.UserInfo; import com.jxau.mall.user.service.IUserService; import org.mindrot.jbcrypt.BCrypt; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * @program: shop * @description: 用户注册控制器类 * @author: guojiani * @create: 2025-04-24 20:20 **/ @RestController @RequestMapping("/user") public class UserInfoController { @Autowired private IUserService userService; @PostMapping("/register") public ResponseVO register(@RequestBody UserInfo userInfo){ // 密码加密 String hashpw = BCrypt.hashpw(userInfo.getPassword(),BCrypt.gensalt()); userInfo.setPassword(hashpw); // 保存到数据表 userService.save(userInfo); return ResponseVO.success(); } @PutMapping("/update") public ResponseVO update(@RequestBody UserInfo userInfo){ userService.updateById(userInfo); return ResponseVO.success(); } }
2301_80339408/shop2-backend
shop/shop/mall-user/src/main/java/com/jxau/mall/user/controller/UserInfoController.java
Java
unknown
1,130