点赞收藏功能细化,问题修复
This commit is contained in:
Generated
+245
@@ -9,6 +9,7 @@
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@iconify/vue": "^5.0.0",
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"axios": "^1.13.5",
|
||||
"element-plus": "^2.13.2",
|
||||
@@ -20,6 +21,7 @@
|
||||
"@types/node": "^24.10.13",
|
||||
"@vitejs/plugin-vue": "^6.0.2",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"less": "^4.5.1",
|
||||
"sass": "^1.97.3",
|
||||
"typescript": "~5.9.3",
|
||||
"unplugin-auto-import": "^21.0.0",
|
||||
@@ -608,6 +610,27 @@
|
||||
"integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@iconify/types/-/types-2.0.0.tgz",
|
||||
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@iconify/vue": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@iconify/vue/-/vue-5.0.0.tgz",
|
||||
"integrity": "sha512-C+KuEWIF5nSBrobFJhT//JS87OZ++QDORB6f2q2Wm6fl2mueSTpFBeBsveK0KW9hWiZ4mNiPjsh6Zs4jjdROSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@iconify/types": "^2.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/cyberalien"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": ">=3"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
@@ -1958,6 +1981,20 @@
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/errno": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmmirror.com/errno/-/errno-0.1.8.tgz",
|
||||
"integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"prr": "~1.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"errno": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
@@ -2198,6 +2235,14 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/graceful-fs": {
|
||||
"version": "4.2.11",
|
||||
"resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
@@ -2243,6 +2288,34 @@
|
||||
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/image-size": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmmirror.com/image-size/-/image-size-0.5.5.tgz",
|
||||
"integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"image-size": "bin/image-size.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/immutable": {
|
||||
"version": "5.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-5.1.4.tgz",
|
||||
@@ -2303,6 +2376,54 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/less": {
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/less/-/less-4.5.1.tgz",
|
||||
"integrity": "sha512-UKgI3/KON4u6ngSsnDADsUERqhZknsVZbnuzlRZXLQCmfC/MDld42fTydUE9B+Mla1AL6SJ/Pp6SlEFi/AVGfw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"copy-anything": "^2.0.1",
|
||||
"parse-node-version": "^1.0.1",
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"lessc": "bin/lessc"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"errno": "^0.1.1",
|
||||
"graceful-fs": "^4.1.2",
|
||||
"image-size": "~0.5.0",
|
||||
"make-dir": "^2.1.0",
|
||||
"mime": "^1.4.1",
|
||||
"needle": "^3.1.0",
|
||||
"source-map": "~0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/copy-anything": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/copy-anything/-/copy-anything-2.0.6.tgz",
|
||||
"integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-what": "^3.14.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/mesqueeb"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/is-what": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmmirror.com/is-what/-/is-what-3.14.1.tgz",
|
||||
"integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/local-pkg": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-1.1.2.tgz",
|
||||
@@ -2371,6 +2492,21 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
}
|
||||
},
|
||||
"node_modules/make-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz",
|
||||
"integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"pify": "^4.0.1",
|
||||
"semver": "^5.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
@@ -2386,6 +2522,20 @@
|
||||
"integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
@@ -2476,6 +2626,24 @@
|
||||
"integrity": "sha512-NzOgmMQ+elxxHeIha+OG/Pv3Oc3p4RU2aBhwWwAqDpXrdTbtRylbRLQztLy8dMMwfl6pclznBdfUhccEn9ZIzw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/needle": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/needle/-/needle-3.3.1.tgz",
|
||||
"integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"iconv-lite": "^0.6.3",
|
||||
"sax": "^1.2.4"
|
||||
},
|
||||
"bin": {
|
||||
"needle": "bin/needle"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/node-addon-api": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/node-addon-api/-/node-addon-api-7.1.1.tgz",
|
||||
@@ -2501,6 +2669,16 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/parse-node-version": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/parse-node-version/-/parse-node-version-1.0.1.tgz",
|
||||
"integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/path-browserify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/path-browserify/-/path-browserify-1.0.1.tgz",
|
||||
@@ -2540,6 +2718,17 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/pify": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/pify/-/pify-4.0.1.tgz",
|
||||
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pinia": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/pinia/-/pinia-3.0.4.tgz",
|
||||
@@ -2607,6 +2796,14 @@
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/prr": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/prr/-/prr-1.0.1.tgz",
|
||||
"integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/quansync": {
|
||||
"version": "0.2.11",
|
||||
"resolved": "https://registry.npmmirror.com/quansync/-/quansync-0.2.11.tgz",
|
||||
@@ -2695,6 +2892,14 @@
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.97.3",
|
||||
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.97.3.tgz",
|
||||
@@ -2716,6 +2921,17 @@
|
||||
"@parcel/watcher": "^2.4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/sax": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/sax/-/sax-1.5.0.tgz",
|
||||
"integrity": "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/scroll-into-view-if-needed": {
|
||||
"version": "2.2.31",
|
||||
"resolved": "https://registry.npmmirror.com/scroll-into-view-if-needed/-/scroll-into-view-if-needed-2.2.31.tgz",
|
||||
@@ -2732,12 +2948,34 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "5.7.2",
|
||||
"resolved": "https://registry.npmmirror.com/semver/-/semver-5.7.2.tgz",
|
||||
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"semver": "bin/semver"
|
||||
}
|
||||
},
|
||||
"node_modules/shallow-equal": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/shallow-equal/-/shallow-equal-1.2.1.tgz",
|
||||
"integrity": "sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
@@ -2813,6 +3051,13 @@
|
||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@iconify/vue": "^5.0.0",
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"axios": "^1.13.5",
|
||||
"element-plus": "^2.13.2",
|
||||
@@ -21,6 +22,7 @@
|
||||
"@types/node": "^24.10.13",
|
||||
"@vitejs/plugin-vue": "^6.0.2",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"less": "^4.5.1",
|
||||
"sass": "^1.97.3",
|
||||
"typescript": "~5.9.3",
|
||||
"unplugin-auto-import": "^21.0.0",
|
||||
|
||||
@@ -71,5 +71,13 @@ export const productApi = {
|
||||
|
||||
getProductsByTag: (tag: string) => {
|
||||
return api.get<ProductVO[]>(`/product/list/tag/${tag}`)
|
||||
},
|
||||
|
||||
likeProduct: (productId: number) => {
|
||||
return api.post<boolean>(`/product/like/${productId}`)
|
||||
},
|
||||
|
||||
unlikeProduct: (productId: number) => {
|
||||
return api.post<boolean>(`/product/unlike/${productId}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ defineExpose({
|
||||
|
||||
// 根据当前路由判断激活的导航项
|
||||
const currentRoute = computed(() => {
|
||||
if (!route || !route.path) return 'home'
|
||||
const path = route.path
|
||||
if (path === '/') return 'home'
|
||||
if (path === '/products') return 'products'
|
||||
|
||||
@@ -39,22 +39,24 @@
|
||||
</div>
|
||||
|
||||
<!-- Banner 轮播区域 -->
|
||||
<div class="banner-carousel">
|
||||
<a-carousel v-if="bannerImages.length > 0" autoplay :autoplay-speed="3000" effect="fade">
|
||||
<div v-for="(image, index) in bannerImages" :key="index" class="banner-slide" @click="handleBannerClick">
|
||||
<img :src="image" alt="Banner" class="banner-img" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
<div v-else class="banner" @click="handleBannerClick">
|
||||
<div class="banner-content">
|
||||
<a-tag color="red" class="banner-tag">限时优惠</a-tag>
|
||||
<h3>Get Winter Discount</h3>
|
||||
<h2>20% Off</h2>
|
||||
<p>For Children</p>
|
||||
<a-button type="primary" size="small" class="banner-btn">立即购买</a-button>
|
||||
</div>
|
||||
<div class="banner-image">
|
||||
<div class="img-placeholder">Banner</div>
|
||||
<div class="banner-container">
|
||||
<div class="banner-carousel">
|
||||
<a-carousel v-if="bannerImages.length > 0" autoplay :autoplay-speed="3000" effect="fade">
|
||||
<div v-for="(image, index) in bannerImages" :key="index" class="banner-slide" @click="handleBannerClick">
|
||||
<img :src="image" alt="Banner" class="banner-img" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
<div v-else class="banner" @click="handleBannerClick">
|
||||
<div class="banner-content">
|
||||
<a-tag color="red" class="banner-tag">限时优惠</a-tag>
|
||||
<h3>Get Winter Discount</h3>
|
||||
<h2>20% Off</h2>
|
||||
<p>For Children</p>
|
||||
<a-button type="primary" size="small" class="banner-btn">立即购买</a-button>
|
||||
</div>
|
||||
<div class="banner-image">
|
||||
<div class="img-placeholder">Banner</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -418,20 +420,34 @@ const handleProductClick = (item: any) => {
|
||||
}
|
||||
|
||||
/* Banner轮播区域 */
|
||||
.banner-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 15px 0;
|
||||
max-width: 1200px;
|
||||
width: 100%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.banner-carousel {
|
||||
margin: 15px 20px;
|
||||
width: 100%;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
aspect-ratio: 4/3;
|
||||
max-height: 450px;
|
||||
}
|
||||
|
||||
.banner-carousel :deep(.ant-carousel) {
|
||||
border-radius: 16px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-slide {
|
||||
width: 100%;
|
||||
height: 180px;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -440,6 +456,7 @@ const handleProductClick = (item: any) => {
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 16px;
|
||||
object-fit: stretch;
|
||||
}
|
||||
|
||||
/* 轮播指示器样式 */
|
||||
@@ -465,10 +482,10 @@ const handleProductClick = (item: any) => {
|
||||
}
|
||||
|
||||
.banner {
|
||||
margin: 15px 20px;
|
||||
width: 100%;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 20px;
|
||||
height: 160px;
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -55,16 +55,19 @@
|
||||
<div class="product-meta">
|
||||
<div class="duration">
|
||||
<el-icon><Clock /></el-icon>
|
||||
<span>{{ product.estimatedTime }} 分钟</span>
|
||||
<span>{{ product.approximateDuration || '0分钟' }}</span>
|
||||
</div>
|
||||
<div class="stats">
|
||||
<span class="like-count">
|
||||
<el-icon><Star /></el-icon>
|
||||
0 赞
|
||||
<span class="like-count" @click="handleLikeClick" style="cursor: pointer;">
|
||||
<Icon
|
||||
:icon="isLiked ? 'fa:heart' : 'fa:heart-o'"
|
||||
:style="{ color: isLiked ? '#f56c6c' : 'inherit', fontSize: '16px' }"
|
||||
/>
|
||||
{{ product.likeCount || 0 }} 赞
|
||||
</span>
|
||||
<span class="collect-count">
|
||||
<span class="collect-count" @click="handleFavoriteClick" style="cursor: pointer;">
|
||||
<el-icon><Collection /></el-icon>
|
||||
0 收藏
|
||||
{{ product.collectCount || 0 }} 收藏
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -112,12 +115,14 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, inject } from 'vue'
|
||||
import { ArrowLeft, Star, Clock, Collection, ShoppingCart, Right } from '@element-plus/icons-vue'
|
||||
import { ArrowLeft, Star, Clock, Collection, ShoppingCart, Right, StarFilled } from '@element-plus/icons-vue'
|
||||
import { Icon } from '@iconify/vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { productApi, type ProductVO } from '@/api/product'
|
||||
import { cartApi } from '@/api/cart'
|
||||
import { wishlistApi } from '@/api/wishlist'
|
||||
import { productLikeApi } from '@/api/productLike'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
// 注入更新购物车数量的方法
|
||||
@@ -141,6 +146,7 @@ const product = ref<ProductVO>({
|
||||
})
|
||||
|
||||
const isFavorite = ref(false)
|
||||
const isLiked = ref(false)
|
||||
const currentImageIndex = ref(0)
|
||||
const productImages = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
@@ -156,6 +162,7 @@ const fetchProductDetail = async () => {
|
||||
|
||||
await loadProductImages()
|
||||
await checkWishlistStatus()
|
||||
await checkLikeStatus()
|
||||
} catch (error) {
|
||||
ElMessage.error('未登录,请先登录')
|
||||
}
|
||||
@@ -180,6 +187,25 @@ const checkWishlistStatus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查用户是否已点赞商品
|
||||
const checkLikeStatus = async () => {
|
||||
if (product.value.id) {
|
||||
const token = localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')
|
||||
if (!token) {
|
||||
isLiked.value = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const status = await productLikeApi.checkLikeStatus(product.value.id)
|
||||
isLiked.value = status
|
||||
} catch (error) {
|
||||
console.error('检查点赞状态失败:', error)
|
||||
isLiked.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载商品图片
|
||||
const loadProductImages = async () => {
|
||||
if (product.value.imageFileIds) {
|
||||
@@ -226,9 +252,21 @@ const handleFavoriteClick = async () => {
|
||||
if (isFavorite.value) {
|
||||
await wishlistApi.removeFromWishlist(product.value.id)
|
||||
ElMessage.success('已取消收藏')
|
||||
// 减少收藏数,确保不小于0
|
||||
if (product.value.collectCount) {
|
||||
product.value.collectCount = Math.max(0, product.value.collectCount - 1)
|
||||
} else {
|
||||
product.value.collectCount = 0
|
||||
}
|
||||
} else {
|
||||
await wishlistApi.addToWishlist(product.value.id)
|
||||
ElMessage.success('已收藏')
|
||||
// 增加收藏数
|
||||
if (product.value.collectCount) {
|
||||
product.value.collectCount += 1
|
||||
} else {
|
||||
product.value.collectCount = 1
|
||||
}
|
||||
}
|
||||
isFavorite.value = !isFavorite.value
|
||||
} catch (error) {
|
||||
@@ -237,6 +275,36 @@ const handleFavoriteClick = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleLikeClick = async () => {
|
||||
if (!product.value.id) return
|
||||
|
||||
try {
|
||||
if (isLiked.value) {
|
||||
await productLikeApi.unlikeProduct(product.value.id)
|
||||
ElMessage.success('已取消点赞')
|
||||
// 减少点赞数,确保不小于0
|
||||
if (product.value.likeCount) {
|
||||
product.value.likeCount = Math.max(0, product.value.likeCount - 1)
|
||||
} else {
|
||||
product.value.likeCount = 0
|
||||
}
|
||||
} else {
|
||||
await productLikeApi.likeProduct(product.value.id)
|
||||
ElMessage.success('已点赞')
|
||||
// 增加点赞数
|
||||
if (product.value.likeCount) {
|
||||
product.value.likeCount += 1
|
||||
} else {
|
||||
product.value.likeCount = 1
|
||||
}
|
||||
}
|
||||
isLiked.value = !isLiked.value
|
||||
} catch (error) {
|
||||
console.error('操作点赞失败:', error)
|
||||
ElMessage.error('操作失败,请重试')
|
||||
}
|
||||
}
|
||||
|
||||
const handleAddToCart = async () => {
|
||||
try {
|
||||
await cartApi.addToCart({ productId: product.value.id, quantity: 1 })
|
||||
@@ -288,69 +356,59 @@ onMounted(() => {
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.back-btn:hover {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.actions {
|
||||
width: 40px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.actions .el-icon {
|
||||
cursor: pointer;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
.actions .active {
|
||||
color: #FFD700;
|
||||
fill: #FFD700;
|
||||
}
|
||||
|
||||
.actions .active svg {
|
||||
fill: #FFD700;
|
||||
.actions .el-icon.active {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.product-image-container {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
background: white;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.image-carousel {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
scroll-snap-type: x mandatory;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.image-carousel::-webkit-scrollbar {
|
||||
display: none;
|
||||
overflow: hidden;
|
||||
border-radius: 12px;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
scroll-snap-align: start;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.3s;
|
||||
min-width: 100%;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.carousel-item.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.carousel-item:not(.active) {
|
||||
opacity: 0.6;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
@@ -360,52 +418,51 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.carousel-indicators {
|
||||
position: absolute;
|
||||
bottom: 12px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.indicator {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
background: #ddd;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.indicator.active {
|
||||
background: white;
|
||||
width: 24px;
|
||||
border-radius: 4px;
|
||||
background: #409eff;
|
||||
}
|
||||
|
||||
.product-image-placeholder {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f5f5;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.product-letter {
|
||||
font-size: 80px;
|
||||
font-weight: bold;
|
||||
color: rgba(0,0,0,0.1);
|
||||
background: #f8f8f8;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
padding: 20px;
|
||||
background: white;
|
||||
margin-bottom: 10px;
|
||||
padding: 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.info-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
@@ -413,106 +470,92 @@ onMounted(() => {
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
margin-right: 15px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.price-tag {
|
||||
font-size: 22px;
|
||||
color: #ff4d4f;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.shop-info {
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.shop-name {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
background: #f8f8f8;
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.product-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
padding: 12px;
|
||||
background: #f8f8f8;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 15px;
|
||||
padding: 10px 0;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.duration {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: 5px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.like-count, .collect-count {
|
||||
.like-count,
|
||||
.collect-count {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
gap: 5px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.like-count .el-icon.active {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.tags {
|
||||
margin-bottom: 16px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
background: white;
|
||||
margin-top: 10px;
|
||||
position: sticky;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
z-index: 90;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding: 15px 20px;
|
||||
background: white;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.add-cart-btn, .buy-now-btn {
|
||||
flex: 1;
|
||||
height: 50px;
|
||||
border-radius: 25px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.add-cart-btn {
|
||||
background-color: #f5f5f5;
|
||||
border: 1px solid #e8e8e8;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
height: 44px;
|
||||
border-radius: 22px;
|
||||
}
|
||||
|
||||
.buy-now-btn {
|
||||
background-color: #ff4d4f;
|
||||
border: none;
|
||||
color: white;
|
||||
flex: 1;
|
||||
height: 44px;
|
||||
border-radius: 22px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -61,10 +61,10 @@
|
||||
<div class="product-info">
|
||||
<p class="name">{{ item.title || item.name }}</p>
|
||||
<div class="product-meta">
|
||||
<span class="duration">{{ item.estimatedTime }} 分钟</span>
|
||||
<span class="duration">{{ item.approximateDuration || '0分钟' }}</span>
|
||||
<div class="stats">
|
||||
<span class="like-count">0 赞</span>
|
||||
<span class="collect-count">0 收藏</span>
|
||||
<span class="like-count">{{ item.likeCount || 0 }} 赞</span>
|
||||
<span class="collect-count">{{ item.collectCount || 0 }} 收藏</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 标签展示 -->
|
||||
@@ -146,7 +146,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
LeftOutlined,
|
||||
@@ -160,6 +160,21 @@ import { tagApi, type TagVO } from '@/api/tag'
|
||||
import { cartApi } from '@/api/cart'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
// 格式化分钟数显示
|
||||
const formatDuration = (minutes: number): string => {
|
||||
if (minutes < 60) {
|
||||
return `${minutes} 分钟`
|
||||
} else {
|
||||
const hours = Math.floor(minutes / 60)
|
||||
const remainingMinutes = minutes % 60
|
||||
if (remainingMinutes === 0) {
|
||||
return `${hours} 小时`
|
||||
} else {
|
||||
return `${hours} 小时 ${remainingMinutes} 分钟`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// 标签列表
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.ProductDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 商品信息表 Mapper
|
||||
@@ -11,4 +13,40 @@ import com.xiaowang.yuminailcore.entity.ProductDO;
|
||||
* @date 2026-02-13
|
||||
*/
|
||||
public interface ProductMapper extends BaseMapper<ProductDO> {
|
||||
|
||||
/**
|
||||
* 增加商品收藏数
|
||||
*
|
||||
* @param productId 商品ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE t_product SET collect_count = collect_count + 1 WHERE id = #{productId}")
|
||||
int incrementCollectCount(@Param("productId") Long productId);
|
||||
|
||||
/**
|
||||
* 减少商品收藏数
|
||||
*
|
||||
* @param productId 商品ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE t_product SET collect_count = CASE WHEN collect_count > 0 THEN collect_count - 1 ELSE 0 END WHERE id = #{productId}")
|
||||
int decrementCollectCount(@Param("productId") Long productId);
|
||||
|
||||
/**
|
||||
* 增加商品点赞数
|
||||
*
|
||||
* @param productId 商品ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE t_product SET like_count = like_count + 1 WHERE id = #{productId}")
|
||||
int incrementLikeCount(@Param("productId") Long productId);
|
||||
|
||||
/**
|
||||
* 减少商品点赞数
|
||||
*
|
||||
* @param productId 商品ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE t_product SET like_count = CASE WHEN like_count > 0 THEN like_count - 1 ELSE 0 END WHERE id = #{productId}")
|
||||
int decrementLikeCount(@Param("productId") Long productId);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,22 @@ public interface ProductService extends IService<ProductDO> {
|
||||
*/
|
||||
boolean updateProduct(Long id, ProductDTO productDTO);
|
||||
|
||||
/**
|
||||
* 增加商品点赞数
|
||||
*
|
||||
* @param productId 商品ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int incrementLikeCount(Long productId);
|
||||
|
||||
/**
|
||||
* 减少商品点赞数
|
||||
*
|
||||
* @param productId 商品ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int decrementLikeCount(Long productId);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
|
||||
+10
@@ -78,6 +78,16 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
return removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int incrementLikeCount(Long productId) {
|
||||
return productMapper.incrementLikeCount(productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int decrementLikeCount(Long productId) {
|
||||
return productMapper.decrementLikeCount(productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductVO getProductById(Long id) {
|
||||
ProductDO productDO = productMapper.selectById(id);
|
||||
|
||||
+14
-1
@@ -6,11 +6,13 @@ import com.xiaowang.yuminailcore.dto.WishlistDTO;
|
||||
import com.xiaowang.yuminailcore.vo.ProductVO;
|
||||
import com.xiaowang.yuminailcore.entity.WishlistDO;
|
||||
import com.xiaowang.yuminailcore.mapper.WishlistMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.service.WishlistService;
|
||||
import com.xiaowang.yuminailcore.service.ProductService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -21,7 +23,11 @@ public class WishlistServiceImpl extends ServiceImpl<WishlistMapper, WishlistDO>
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
|
||||
@Autowired
|
||||
private ProductMapper productMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addToWishlist(Long userId, Long productId) {
|
||||
LambdaQueryWrapper<WishlistDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(WishlistDO::getUserId, userId);
|
||||
@@ -31,15 +37,22 @@ public class WishlistServiceImpl extends ServiceImpl<WishlistMapper, WishlistDO>
|
||||
wishlistDO.setUserId(userId);
|
||||
wishlistDO.setProductId(productId);
|
||||
save(wishlistDO);
|
||||
// 增加商品收藏数
|
||||
productMapper.incrementCollectCount(productId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void removeFromWishlist(Long userId, Long productId) {
|
||||
LambdaQueryWrapper<WishlistDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(WishlistDO::getUserId, userId);
|
||||
wrapper.eq(WishlistDO::getProductId, productId);
|
||||
remove(wrapper);
|
||||
if (count(wrapper) > 0) {
|
||||
remove(wrapper);
|
||||
// 减少商品收藏数
|
||||
productMapper.decrementCollectCount(productId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -641,3 +641,18 @@ WHERE p.is_delete = 0
|
||||
'nail_artist:view',
|
||||
'nail_artist:edit'
|
||||
);
|
||||
-- 商品点赞记录表
|
||||
CREATE TABLE t_product_like (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '点赞记录唯一主键ID'
|
||||
PRIMARY KEY COMMENT '商品点赞主键索引',
|
||||
user_id BIGINT UNSIGNED NOT NULL COMMENT '关联用户表主键',
|
||||
product_id BIGINT UNSIGNED NOT NULL COMMENT '关联商品表主键',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete TINYINT UNSIGNED DEFAULT 0 NULL COMMENT '逻辑删除:0-未删除,1-已删除',
|
||||
CONSTRAINT uk_user_product_like
|
||||
UNIQUE (user_id, product_id) COMMENT '用户-商品唯一索引'
|
||||
) COMMENT '商品点赞记录表';
|
||||
|
||||
CREATE INDEX idx_user_id_like ON t_product_like (user_id) COMMENT '按用户查询点赞的索引';
|
||||
CREATE INDEX idx_product_id_like ON t_product_like (product_id) COMMENT '按商品查询点赞的索引';
|
||||
@@ -9,6 +9,12 @@ spring:
|
||||
- Path=/api/product/**
|
||||
filters:
|
||||
- RewritePath=/api/(?<remaining>.*), /${remaining}
|
||||
- id: product-like-route
|
||||
uri: lb://yumi-nail-core
|
||||
predicates:
|
||||
- Path=/api/product-like/**
|
||||
filters:
|
||||
- RewritePath=/api/(?<remaining>.*), /${remaining}
|
||||
- id: shop-route
|
||||
uri: lb://yumi-nail-core
|
||||
predicates:
|
||||
@@ -94,4 +100,4 @@ spring:
|
||||
predicates:
|
||||
- Path=/admin/api/**
|
||||
filters:
|
||||
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
||||
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
||||
|
||||
Reference in New Issue
Block a user