功能:完善门店能力与用户安全配置
This commit is contained in:
Generated
+13
@@ -16,14 +16,27 @@
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="D:/apache-maven-3.9.9/repository/xiaowang/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" />
|
||||
<entry name="D:/apache-maven-3.9.9/repository/xiaowang/org/projectlombok/lombok/1.18.32/lombok-1.18.32.jar" />
|
||||
</processorPath>
|
||||
<module name="YumiNail-Core" />
|
||||
</profile>
|
||||
<profile name="Annotation profile for YumiNail-Calendar-Gateway" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="D:/apache-maven-3.9.9/repository/xiaowang/org/projectlombok/lombok/1.18.32/lombok-1.18.32.jar" />
|
||||
</processorPath>
|
||||
<module name="YumiNail-Calendar-Gateway" />
|
||||
<module name="YumiNail-Calendar-Core" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="MessageHub" options="-parameters" />
|
||||
<module name="YumiNail-Calendar-Core" options="-parameters" />
|
||||
<module name="YumiNail-Calendar-Gateway" options="-parameters" />
|
||||
<module name="YumiNail-Core" options="-parameters" />
|
||||
<module name="YumiNail-Gateway" options="-parameters" />
|
||||
</option>
|
||||
|
||||
Generated
+23
@@ -14,5 +14,28 @@
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="yumi_nail@localhost" uuid="fb5bc7bc-5d79-4037-aeb2-e0b14cfc8f4c">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<imported>true</imported>
|
||||
<remarks>$PROJECT_DIR$/YumiNail-Core/src/main/resources/application.yaml</remarks>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/yumi_nail?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="yumi_nail_calendar@localhost" uuid="dcfd1e7a-246b-4802-8b51-5e92f3f0eab0">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<imported>true</imported>
|
||||
<remarks>$PROJECT_DIR$/YumiNail-Calendar-Core/src/main/resources/application.yaml</remarks>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/yumi_nail_calendar?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+2
@@ -2,6 +2,8 @@
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/MessageHub/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Calendar-Core/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Calendar-Gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Core/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Gateway/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
|
||||
Generated
+2
@@ -7,6 +7,8 @@
|
||||
<option value="$PROJECT_DIR$/MessageHub/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/YumiNail-Core/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/YumiNail-Gateway/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/YumiNail-Calendar-Core/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/YumiNail-Calendar-Gateway/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
Generated
+3
-1
@@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Core/src/main/resources/files/2026-03-20_init_admin_permission_template.sql" dialect="MySQL" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Core/src/main/resources/files/2026-03-20_user_asset_vip_coupon_permission_patch.sql" dialect="MySQL" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Core/src/main/resources/files/YumiNail-back.sql" dialect="MySQL" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Core/src/main/resources/files/YumiNail.sql" dialect="MySQL" />
|
||||
<file url="file://$PROJECT_DIR$/YumiNail-Core/src/main/resources/files/cart_order.sql" dialect="MySQL" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
@@ -78,5 +82,12 @@ module.exports = {
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
getCurrentAgreements() {
|
||||
return request({
|
||||
url: '/legal-agreement/current',
|
||||
method: 'GET'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
const actionGuard = require('../utils/action-guard')
|
||||
const { API_BASE_URL, REQUEST_TIMEOUT } = require('../utils/config')
|
||||
@@ -39,6 +43,86 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
// 我的页常用数据:
|
||||
// 资产、余额流水、消息、公告、VIP 充值档位和所属关系都从这里拿。
|
||||
getMyAsset() {
|
||||
return request({
|
||||
url: '/user/asset/me'
|
||||
})
|
||||
},
|
||||
|
||||
getMyBalanceHistory() {
|
||||
return request({
|
||||
url: '/user/balance/history/me'
|
||||
})
|
||||
},
|
||||
|
||||
listMyMessages() {
|
||||
return request({
|
||||
url: '/system-message/my/list'
|
||||
})
|
||||
},
|
||||
|
||||
listMyPopupMessages() {
|
||||
return request({
|
||||
url: '/system-message/my/popup'
|
||||
})
|
||||
},
|
||||
|
||||
getMyUnreadMessageCount() {
|
||||
return request({
|
||||
url: '/system-message/my/unread-count'
|
||||
})
|
||||
},
|
||||
|
||||
markMessagePopupShown(id) {
|
||||
return request({
|
||||
url: `/system-message/my/${id}/popup-shown`,
|
||||
method: 'PUT',
|
||||
data: {}
|
||||
})
|
||||
},
|
||||
|
||||
markMessageRead(id) {
|
||||
return request({
|
||||
url: `/system-message/my/${id}/read`,
|
||||
method: 'PUT',
|
||||
data: {}
|
||||
})
|
||||
},
|
||||
|
||||
listMyAnnouncements() {
|
||||
return request({
|
||||
url: '/announcement/my/list'
|
||||
})
|
||||
},
|
||||
|
||||
// 这里只是“展示型充值档位”,不发起支付、不改余额。
|
||||
listMyVipRechargePlans() {
|
||||
return request({
|
||||
url: '/vip-recharge-plan/my/list'
|
||||
})
|
||||
},
|
||||
|
||||
getShopManagerContact(shopId) {
|
||||
return request({
|
||||
url: `/contact-info/shop/${shopId}/manager`
|
||||
})
|
||||
},
|
||||
|
||||
getProductArtistContact(productId, artistId) {
|
||||
return request({
|
||||
url: `/contact-info/product/${productId}/artist/${artistId}`
|
||||
})
|
||||
},
|
||||
|
||||
getOrderArtistContact(orderId, artistId) {
|
||||
return request({
|
||||
url: `/contact-info/order/${orderId}/artist`,
|
||||
data: artistId ? { artistId } : {}
|
||||
})
|
||||
},
|
||||
|
||||
updateUserInfo(data) {
|
||||
return request({
|
||||
url: '/user/update',
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Mini program API wrapper for this module.
|
||||
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
"pages/orders/index",
|
||||
"pages/wishlist/index",
|
||||
"pages/coupons/index",
|
||||
"pages/vip-center/index",
|
||||
"pages/notifications/index",
|
||||
"pages/settings/index"
|
||||
],
|
||||
"window": {
|
||||
|
||||
@@ -52,7 +52,9 @@ Component({
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
observer: '_showChange',
|
||||
observer(show) {
|
||||
this._showChange(show)
|
||||
},
|
||||
},
|
||||
delta: {
|
||||
type: Number,
|
||||
@@ -64,7 +66,9 @@ Component({
|
||||
},
|
||||
},
|
||||
observers: {
|
||||
'back, showBack, isTabPage': 'updateResolvedBack',
|
||||
'back, showBack, isTabPage': function () {
|
||||
this.updateResolvedBack()
|
||||
},
|
||||
},
|
||||
data: {
|
||||
displayStyle: '',
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
</view>
|
||||
<view class="product-body">
|
||||
<view class="product-title">{{item.displayTitle}}</view>
|
||||
<view wx:if="{{item.shopNameText}}" class="product-shop">{{item.shopNameText}}</view>
|
||||
<view wx:if="{{!showMeta && item.metaText}}" class="product-meta">{{item.metaText}}</view>
|
||||
<view wx:if="{{item.tagsPreview && item.tagsPreview.length}}" class="product-tags">
|
||||
<text wx:for="{{item.tagsPreview}}" wx:key="*this" class="tag-item">{{item}}</text>
|
||||
|
||||
@@ -215,3 +215,13 @@
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-shop {
|
||||
margin-top: 6rpx;
|
||||
color: #8f6e7a;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.45;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ const {
|
||||
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
|
||||
/**
|
||||
* auth page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 108
|
||||
@@ -54,6 +58,10 @@ Page({
|
||||
miniShopDisplayName: '',
|
||||
miniShopNewUser: false,
|
||||
miniShopSubmitting: false,
|
||||
agreementAccepted: false,
|
||||
agreements: [],
|
||||
agreementModalVisible: false,
|
||||
selectedAgreement: null,
|
||||
form: {
|
||||
account: '',
|
||||
password: '',
|
||||
@@ -71,6 +79,10 @@ Page({
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.ensureKeyboardSafe()
|
||||
this.setData({
|
||||
@@ -79,20 +91,33 @@ Page({
|
||||
})
|
||||
this.detectWechatMiniCapability()
|
||||
this.loadShopOptions()
|
||||
this.loadAgreements()
|
||||
this.consumePendingWechatMiniLogin()
|
||||
this.waitForPendingWechatMiniAutoLogin()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.ensureKeyboardSafe()
|
||||
this.consumePendingWechatMiniLogin()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onHide` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `onUnload` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
@@ -100,6 +125,10 @@ Page({
|
||||
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
* `ensureKeyboardSafe` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 108,
|
||||
@@ -107,14 +136,26 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleKeyboardFocus` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleKeyboardFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleKeyboardBlur` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleKeyboardBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `detectWechatMiniCapability` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
detectWechatMiniCapability() {
|
||||
let supported = false
|
||||
let disabledReason = ''
|
||||
@@ -122,6 +163,10 @@ Page({
|
||||
try {
|
||||
supported = wx.canIUse('button.open-type.getPhoneNumber')
|
||||
const systemInfo = wx.getSystemInfoSync()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (systemInfo && systemInfo.platform === 'devtools') {
|
||||
supported = false
|
||||
disabledReason = '当前环境无法使用微信手机号登录,请使用账号密码或验证码登录'
|
||||
@@ -130,6 +175,10 @@ Page({
|
||||
supported = false
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!supported && !disabledReason) {
|
||||
disabledReason = '当前环境无法使用微信手机号登录,请使用账号密码或验证码登录'
|
||||
}
|
||||
@@ -140,6 +189,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `waitForPendingWechatMiniAutoLogin` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
waitForPendingWechatMiniAutoLogin() {
|
||||
const app = getApp()
|
||||
if (
|
||||
@@ -167,13 +220,25 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `consumePendingWechatMiniLogin` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
consumePendingWechatMiniLogin() {
|
||||
const app = getApp()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!app || typeof app.consumePendingWechatMiniLogin !== 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
const pending = app.consumePendingWechatMiniLogin()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (pending && pending.status === 'SELECT_SHOP') {
|
||||
this.openMiniShopSelector(pending)
|
||||
}
|
||||
@@ -193,6 +258,87 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async loadAgreements() {
|
||||
try {
|
||||
const agreements = await authApi.getCurrentAgreements()
|
||||
this.setData({
|
||||
agreements: Array.isArray(agreements) ? agreements : []
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: '协议内容加载失败,请稍后重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
buildAgreementPayload() {
|
||||
const agreementVersions = {}
|
||||
;(this.data.agreements || []).forEach((item) => {
|
||||
if (item && item.agreementType && item.version) {
|
||||
agreementVersions[item.agreementType] = item.version
|
||||
}
|
||||
})
|
||||
return {
|
||||
agreementAccepted: !!this.data.agreementAccepted,
|
||||
agreementVersions,
|
||||
clientType: 'WECHAT_MINI'
|
||||
}
|
||||
},
|
||||
|
||||
ensureAgreementAccepted() {
|
||||
if (!this.data.agreementAccepted) {
|
||||
wx.showToast({
|
||||
title: '请先阅读并同意用户协议和隐私政策',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
const versions = this.buildAgreementPayload().agreementVersions
|
||||
if (!versions.USER_TERMS || !versions.PRIVACY_POLICY) {
|
||||
wx.showToast({
|
||||
title: '协议版本加载中,请稍后再试',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
|
||||
handleAgreementToggle() {
|
||||
this.setData({
|
||||
agreementAccepted: !this.data.agreementAccepted
|
||||
})
|
||||
},
|
||||
|
||||
openAgreement(event) {
|
||||
const type = event.currentTarget.dataset.type
|
||||
const selectedAgreement = (this.data.agreements || []).find((item) => item.agreementType === type)
|
||||
if (!selectedAgreement) {
|
||||
wx.showToast({
|
||||
title: '协议内容暂不可用',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
selectedAgreement,
|
||||
agreementModalVisible: true
|
||||
})
|
||||
},
|
||||
|
||||
closeAgreementModal() {
|
||||
this.setData({
|
||||
agreementModalVisible: false,
|
||||
selectedAgreement: null
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleTabChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleTabChange(event) {
|
||||
const tab = event.currentTarget.dataset.tab
|
||||
resetKeyboardSafe(this)
|
||||
@@ -210,6 +356,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleLoginTypeChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleLoginTypeChange(event) {
|
||||
const type = event.currentTarget.dataset.type
|
||||
resetKeyboardSafe(this)
|
||||
@@ -227,6 +377,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleShowTraditionalLogin` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleShowTraditionalLogin() {
|
||||
resetKeyboardSafe(this)
|
||||
this.setData({
|
||||
@@ -235,6 +389,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleToggleResetPanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleToggleResetPanel() {
|
||||
resetKeyboardSafe(this)
|
||||
this.setData({
|
||||
@@ -242,6 +400,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleInputChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = event.detail.value
|
||||
@@ -249,7 +411,15 @@ Page({
|
||||
[`form.${field}`]: value
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (field === 'account') {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.activeTab === 'login') {
|
||||
patch.loginAccountStatusText = ''
|
||||
patch.loginAccountStatusType = ''
|
||||
@@ -267,7 +437,15 @@ Page({
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (field === 'phone') {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.activeTab === 'register') {
|
||||
patch.registerPhoneStatusText = ''
|
||||
patch.registerPhoneStatusType = ''
|
||||
@@ -284,6 +462,10 @@ Page({
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleResetInputChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleResetInputChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -291,6 +473,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleRegisterShopChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleRegisterShopChange(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const shop = this.data.shops[index]
|
||||
@@ -301,6 +487,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleLoginShopChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleLoginShopChange(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const shop = this.data.loginShops[index]
|
||||
@@ -311,6 +501,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleMiniShopChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleMiniShopChange(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const shop = this.data.miniShops[index]
|
||||
@@ -320,7 +514,15 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleCloseMiniShopSelector` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCloseMiniShopSelector() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.miniShopSubmitting) {
|
||||
return
|
||||
}
|
||||
@@ -329,7 +531,15 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleResumeMiniShopSelector` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleResumeMiniShopSelector() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.miniShopTicket || !this.data.miniShops.length) {
|
||||
return
|
||||
}
|
||||
@@ -342,15 +552,27 @@ Page({
|
||||
async handleAccountBlur() {
|
||||
this.handleKeyboardBlur()
|
||||
const account = this.data.form.account.trim()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!account) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.activeTab === 'register') {
|
||||
await this.checkRegisterAccountAvailability()
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.loginType !== 'password') {
|
||||
return
|
||||
}
|
||||
@@ -364,10 +586,18 @@ Page({
|
||||
async handlePhoneBlur() {
|
||||
this.handleKeyboardBlur()
|
||||
const phone = this.data.form.phone.trim()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!phone) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.activeTab === 'register') {
|
||||
if (phoneRegex.test(phone)) {
|
||||
await this.checkRegisterPhoneAvailability()
|
||||
@@ -382,6 +612,10 @@ Page({
|
||||
await this.loadLoginShopsByPhone()
|
||||
},
|
||||
|
||||
/**
|
||||
* `applyLoginShopSelection` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
applyLoginShopSelection(selection) {
|
||||
const shops = Array.isArray(selection && selection.shops) ? selection.shops : []
|
||||
const allowLoginShopless = Boolean(selection && selection.allowShoplessLogin)
|
||||
@@ -389,6 +623,10 @@ Page({
|
||||
let loginShopDisplayName = ''
|
||||
let shopId = ''
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!allowLoginShopless && shops.length === 1) {
|
||||
loginShopIndex = 0
|
||||
loginShopDisplayName = shops[0].shopName || ''
|
||||
@@ -482,6 +720,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `startCountdown` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
startCountdown(fieldName) {
|
||||
this.setData({
|
||||
[fieldName]: 60
|
||||
@@ -493,6 +735,10 @@ Page({
|
||||
[fieldName]: nextValue
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (nextValue <= 0) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
@@ -500,6 +746,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleSendCode() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.countdown > 0) {
|
||||
return
|
||||
}
|
||||
@@ -513,8 +763,16 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.activeTab === 'register') {
|
||||
const phoneAvailable = await this.checkRegisterPhoneAvailability()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!phoneAvailable) {
|
||||
wx.showToast({
|
||||
title: this.data.registerPhoneStatusText || '该手机号已被注册',
|
||||
@@ -525,7 +783,10 @@ Page({
|
||||
}
|
||||
|
||||
try {
|
||||
await runWithLoading(() => userApi.sendVerificationCode({ phone }))
|
||||
await runWithLoading(() => userApi.sendVerificationCode({
|
||||
phone,
|
||||
sceneCode: this.data.activeTab === 'register' ? 'USER_REGISTER_SMS_CODE' : 'USER_LOGIN_SMS_CODE'
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
@@ -540,6 +801,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleSendForgotCode() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.forgotCountdown > 0) {
|
||||
return
|
||||
}
|
||||
@@ -554,7 +819,10 @@ Page({
|
||||
}
|
||||
|
||||
try {
|
||||
await runWithLoading(() => authApi.sendVerificationCode({ phone }))
|
||||
await runWithLoading(() => authApi.sendVerificationCode({
|
||||
phone,
|
||||
sceneCode: 'USER_RESET_PASSWORD_SMS_CODE'
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
@@ -568,8 +836,16 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `validateLoginForm` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
validateLoginForm() {
|
||||
const form = this.data.form
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.loginType === 'password') {
|
||||
if (!form.account.trim() || !form.password) {
|
||||
return '请输入账号和密码'
|
||||
@@ -578,6 +854,10 @@ Page({
|
||||
return '请输入正确的手机号和验证码'
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.allowLoginShopless && this.data.loginShops.length && !form.shopId) {
|
||||
return '请选择登录门店'
|
||||
}
|
||||
@@ -599,12 +879,24 @@ Page({
|
||||
if (!form.verificationCode.trim()) {
|
||||
return '请输入验证码'
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!form.password || form.password.length < 6) {
|
||||
return '密码至少 6 位'
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (form.password !== form.confirmPassword) {
|
||||
return '两次输入的密码不一致'
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!form.shopId) {
|
||||
return '请选择门店'
|
||||
}
|
||||
@@ -614,6 +906,10 @@ Page({
|
||||
this.checkRegisterPhoneAvailability()
|
||||
])
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!accountAvailable || !phoneAvailable) {
|
||||
return '请先处理注册信息中的占用问题'
|
||||
}
|
||||
@@ -622,30 +918,45 @@ Page({
|
||||
},
|
||||
|
||||
async handleSubmit() {
|
||||
if (!this.ensureAgreementAccepted()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({
|
||||
loading: true
|
||||
})
|
||||
|
||||
try {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.activeTab === 'login') {
|
||||
const loginError = this.validateLoginForm()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (loginError) {
|
||||
throw new Error(loginError)
|
||||
}
|
||||
|
||||
let payload
|
||||
await runWithLoading(async () => {
|
||||
const agreementPayload = this.buildAgreementPayload()
|
||||
payload = this.data.loginType === 'phone'
|
||||
? await authApi.phoneLogin({
|
||||
phone: this.data.form.phone.trim(),
|
||||
verificationCode: this.data.form.verificationCode.trim(),
|
||||
shopId: this.data.form.shopId || undefined
|
||||
shopId: this.data.form.shopId || undefined,
|
||||
...agreementPayload
|
||||
})
|
||||
: await authApi.login({
|
||||
account: this.data.form.account.trim(),
|
||||
password: this.data.form.password,
|
||||
rememberMe: true,
|
||||
shopId: this.data.form.shopId || undefined
|
||||
shopId: this.data.form.shopId || undefined,
|
||||
...agreementPayload
|
||||
})
|
||||
})
|
||||
|
||||
@@ -654,6 +965,10 @@ Page({
|
||||
}
|
||||
|
||||
const registerError = await this.validateRegisterForm()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (registerError) {
|
||||
throw new Error(registerError)
|
||||
}
|
||||
@@ -664,7 +979,8 @@ Page({
|
||||
nickname: this.data.form.nickname.trim(),
|
||||
phone: this.data.form.phone.trim(),
|
||||
verificationCode: this.data.form.verificationCode.trim(),
|
||||
shopId: this.data.form.shopId
|
||||
shopId: this.data.form.shopId,
|
||||
...this.buildAgreementPayload()
|
||||
}))
|
||||
|
||||
wx.showToast({
|
||||
@@ -708,6 +1024,10 @@ Page({
|
||||
})
|
||||
return
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!form.newPassword || form.newPassword.length < 6) {
|
||||
wx.showToast({
|
||||
title: '新密码至少 6 位',
|
||||
@@ -750,6 +1070,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleWechatMiniUnavailableTap` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleWechatMiniUnavailableTap() {
|
||||
wx.showToast({
|
||||
title: this.data.wechatMiniDisabledReason || '请使用账号密码或验证码登录',
|
||||
@@ -758,12 +1082,24 @@ Page({
|
||||
},
|
||||
|
||||
async handleWechatMiniPhoneLogin(event) {
|
||||
if (!this.ensureAgreementAccepted()) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.wechatMiniSupported || this.data.wechatMiniLoading) {
|
||||
this.handleWechatMiniUnavailableTap()
|
||||
return
|
||||
}
|
||||
|
||||
const detail = event.detail || {}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!detail.code) {
|
||||
wx.showToast({
|
||||
title: this.resolveWechatAuthorizeError(detail),
|
||||
@@ -781,7 +1117,8 @@ Page({
|
||||
const result = await runWithLoading(() => authApi.wechatMiniPhoneLogin({
|
||||
wxCode,
|
||||
phoneCode: detail.code,
|
||||
preferredShopId: authStore.getPreferredMiniLoginShopId() || undefined
|
||||
preferredShopId: authStore.getPreferredMiniLoginShopId() || undefined,
|
||||
...this.buildAgreementPayload()
|
||||
}))
|
||||
await this.handleWechatMiniResult(result)
|
||||
} catch (error) {
|
||||
@@ -797,7 +1134,15 @@ Page({
|
||||
},
|
||||
|
||||
async handleConfirmMiniShopLogin() {
|
||||
if (!this.ensureAgreementAccepted()) {
|
||||
return
|
||||
}
|
||||
|
||||
const shop = this.data.miniShops[this.data.miniShopIndex]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.miniShopTicket) {
|
||||
wx.showToast({
|
||||
title: '登录票据已失效,请重新发起微信登录',
|
||||
@@ -805,6 +1150,10 @@ Page({
|
||||
})
|
||||
return
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shop || !shop.id) {
|
||||
wx.showToast({
|
||||
title: '请选择门店',
|
||||
@@ -820,8 +1169,13 @@ Page({
|
||||
try {
|
||||
const result = await runWithLoading(() => authApi.confirmWechatMiniLogin({
|
||||
ticket: this.data.miniShopTicket,
|
||||
shopId: shop.id
|
||||
shopId: shop.id,
|
||||
...this.buildAgreementPayload()
|
||||
}))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!result || result.status !== 'SUCCESS') {
|
||||
throw new Error((result && result.message) || '确认登录失败')
|
||||
}
|
||||
@@ -839,6 +1193,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `resolveWechatAuthorizeError` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
resolveWechatAuthorizeError(detail) {
|
||||
const errMsg = String((detail && detail.errMsg) || '')
|
||||
if (errMsg.includes('user deny') || errMsg.includes('user cancel')) {
|
||||
@@ -850,8 +1208,16 @@ Page({
|
||||
return '未获取到微信手机号授权,请稍后重试。'
|
||||
},
|
||||
|
||||
/**
|
||||
* `requestWechatMiniCode` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
requestWechatMiniCode() {
|
||||
const app = getApp()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (app && typeof app.requestWechatMiniCode === 'function') {
|
||||
return app.requestWechatMiniCode()
|
||||
}
|
||||
@@ -859,6 +1225,10 @@ Page({
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.login({
|
||||
success: res => {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (res && res.code) {
|
||||
resolve(res.code)
|
||||
return
|
||||
@@ -871,15 +1241,27 @@ Page({
|
||||
},
|
||||
|
||||
async handleWechatMiniResult(result) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!result) {
|
||||
throw new Error('微信登录未返回结果')
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (result.status === 'SUCCESS') {
|
||||
await this.finishLogin(result, result.newUser ? '注册并登录成功' : '登录成功')
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (result.status === 'SELECT_SHOP') {
|
||||
this.openMiniShopSelector(result)
|
||||
return
|
||||
@@ -891,9 +1273,17 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `openMiniShopSelector` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
openMiniShopSelector(result) {
|
||||
resetKeyboardSafe(this)
|
||||
const shops = Array.isArray(result && result.shops) ? result.shops : []
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shops.length) {
|
||||
wx.showToast({
|
||||
title: result && result.message ? result.message : '暂无可选门店,请稍后重试',
|
||||
@@ -917,6 +1307,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `clearMiniShopSelector` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
clearMiniShopSelector() {
|
||||
this.setData({
|
||||
showMiniShopSelector: false,
|
||||
@@ -951,10 +1345,22 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `buildAuthHelperText` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
buildAuthHelperText(activeTab, loginType) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (activeTab === 'register') {
|
||||
return '注册前请先选门店'
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (loginType === 'phone') {
|
||||
return '未注册手机号会先选门店'
|
||||
}
|
||||
|
||||
@@ -37,6 +37,16 @@
|
||||
</button>
|
||||
|
||||
<text class="wechat-login-hint">{{wechatMiniSupported ? '单门店可直接登录' : wechatMiniDisabledReason}}</text>
|
||||
|
||||
<view class="agreement-row wechat-agreement" bindtap="handleAgreementToggle">
|
||||
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">
|
||||
<text>我已阅读并同意</text>
|
||||
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
|
||||
<text>和</text>
|
||||
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{miniShopTicket && !showMiniShopSelector}}" class="hint-card mini-login-resume">
|
||||
@@ -216,7 +226,17 @@
|
||||
<text class="aux-link" bindtap="handleToggleResetPanel">忘记密码?</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="primary-btn submit-btn" bindtap="handleSubmit">{{activeTab === 'login' ? '立即登录' : '完成注册'}}</view>
|
||||
<view wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="agreement-row" bindtap="handleAgreementToggle">
|
||||
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">
|
||||
<text>我已阅读并同意</text>
|
||||
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
|
||||
<text>和</text>
|
||||
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{activeTab === 'register' || traditionalLoginExpanded}}" class="primary-btn submit-btn {{agreementAccepted ? '' : 'disabled'}}" bindtap="handleSubmit">{{activeTab === 'login' ? '立即登录' : '完成注册'}}</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{showResetPanel}}" class="page-card reset-card">
|
||||
@@ -303,10 +323,31 @@
|
||||
|
||||
<view wx:if="{{miniShopNewUser}}" class="hint-card mini-shop-note">首次登录会自动注册并绑定手机号。</view>
|
||||
|
||||
<view class="agreement-row mini-shop-agreement" bindtap="handleAgreementToggle">
|
||||
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">
|
||||
<text>我已阅读并同意</text>
|
||||
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
|
||||
<text>和</text>
|
||||
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mini-shop-actions">
|
||||
<view class="secondary-btn mini-shop-action" bindtap="handleCloseMiniShopSelector">稍后再选</view>
|
||||
<view class="primary-btn mini-shop-action" bindtap="handleConfirmMiniShopLogin">{{miniShopSubmitting ? '确认中...' : '确认登录'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{agreementModalVisible}}" class="agreement-mask" catchtouchmove="noop">
|
||||
<view class="agreement-modal">
|
||||
<view class="agreement-modal-title">{{selectedAgreement.title || '协议详情'}}</view>
|
||||
<view class="agreement-modal-meta">版本:{{selectedAgreement.version || '-'}}</view>
|
||||
<scroll-view class="agreement-modal-body" scroll-y="true">
|
||||
<text>{{selectedAgreement.content || '暂无协议内容'}}</text>
|
||||
</scroll-view>
|
||||
<view class="primary-btn agreement-modal-close" bindtap="closeAgreementModal">我知道了</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -238,6 +238,110 @@
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.submit-btn.disabled {
|
||||
opacity: 0.52;
|
||||
}
|
||||
|
||||
.agreement-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 14rpx;
|
||||
margin-top: 22rpx;
|
||||
color: #7a6871;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agreement-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
margin-top: 2rpx;
|
||||
border: 2rpx solid #d9b8c4;
|
||||
border-radius: 10rpx;
|
||||
color: #ffffff;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.agreement-check.checked {
|
||||
border-color: #c6597d;
|
||||
background: #c6597d;
|
||||
}
|
||||
|
||||
.agreement-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
color: #c6597d;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.mini-shop-agreement {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
.wechat-agreement {
|
||||
width: 100%;
|
||||
margin-top: 18rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 28rpx;
|
||||
background: rgba(45, 36, 48, 0.42);
|
||||
}
|
||||
|
||||
.agreement-modal {
|
||||
width: 100%;
|
||||
max-width: 690rpx;
|
||||
max-height: 82vh;
|
||||
padding: 30rpx 28rpx;
|
||||
border-radius: 32rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.agreement-modal-title {
|
||||
font-size: 32rpx;
|
||||
line-height: 1.35;
|
||||
font-weight: 800;
|
||||
color: #2d2430;
|
||||
}
|
||||
|
||||
.agreement-modal-meta {
|
||||
margin-top: 10rpx;
|
||||
font-size: 22rpx;
|
||||
color: #9a8590;
|
||||
}
|
||||
|
||||
.agreement-modal-body {
|
||||
height: 640rpx;
|
||||
max-height: 56vh;
|
||||
margin-top: 22rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 22rpx;
|
||||
background: #fff7f8;
|
||||
color: #5a4a52;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.85;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.agreement-modal-close {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
.mini-shop-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
|
||||
@@ -27,6 +27,10 @@ function getCouponDisplay(coupon) {
|
||||
}
|
||||
|
||||
function calculateCouponDiscount(coupon, amount) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!coupon || amount <= 0) {
|
||||
return 0
|
||||
}
|
||||
@@ -47,32 +51,56 @@ function buildCheckoutIssues(items) {
|
||||
const issues = []
|
||||
const selectedItems = items.filter(item => item.selected)
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!selectedItems.length) {
|
||||
issues.push('请先勾选要结算的作品')
|
||||
return issues
|
||||
}
|
||||
|
||||
const missingArtist = selectedItems.find(item => !item.artistId)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (missingArtist) {
|
||||
issues.push(`请先为“${missingArtist.productTitle}”选择美甲师`)
|
||||
}
|
||||
|
||||
const missingTime = selectedItems.find(item => !item.appointmentValue)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (missingTime) {
|
||||
issues.push(`请先为“${missingTime.productTitle}”选择预约时间`)
|
||||
}
|
||||
|
||||
const expiredTime = selectedItems.find(item => item.appointmentValue && isPastAppointment(item.appointmentValue))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (expiredTime) {
|
||||
issues.push(`“${expiredTime.productTitle}”的预约时间已过,请重新选择`)
|
||||
}
|
||||
|
||||
const shopIds = Array.from(new Set(selectedItems.map(item => item.shopId).filter(Boolean)))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (shopIds.length > 1) {
|
||||
issues.push('跨门店作品请分开结算')
|
||||
}
|
||||
|
||||
const artistIds = Array.from(new Set(selectedItems.map(item => item.artistId).filter(Boolean)))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (artistIds.length > 1) {
|
||||
issues.push('不同美甲师的项目请分开结算')
|
||||
}
|
||||
@@ -80,6 +108,10 @@ function buildCheckoutIssues(items) {
|
||||
return issues
|
||||
}
|
||||
|
||||
/**
|
||||
* cart page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
isLoggedIn: false,
|
||||
@@ -98,6 +130,10 @@ Page({
|
||||
submittingOrder: false
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadCartItems()
|
||||
},
|
||||
@@ -107,14 +143,26 @@ Page({
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* `getSelectedItems` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
getSelectedItems() {
|
||||
return this.data.cartItems.filter(item => item.selected)
|
||||
},
|
||||
|
||||
/**
|
||||
* `getSelectedCoupon` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
getSelectedCoupon() {
|
||||
return this.data.availableCoupons.find(item => item.key === this.data.selectedCouponKey) || null
|
||||
},
|
||||
|
||||
/**
|
||||
* `refreshSummary` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
refreshSummary() {
|
||||
const selectedItems = this.getSelectedItems()
|
||||
const selectedCoupon = this.getSelectedCoupon()
|
||||
@@ -143,6 +191,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.setData({
|
||||
cartItems: [],
|
||||
@@ -163,7 +215,10 @@ Page({
|
||||
const availableArtists = Array.isArray(item.availableArtists) ? item.availableArtists.map(artist => ({
|
||||
id: artist.id,
|
||||
name: artist.name,
|
||||
avatar: artist.avatar
|
||||
avatar: artist.avatar,
|
||||
userType: artist.userType,
|
||||
roleLabel: artist.roleLabel,
|
||||
participateProduction: artist.participateProduction
|
||||
})) : []
|
||||
const artist = availableArtists.find(current => String(current.id) === String(item.artistId || ''))
|
||||
|
||||
@@ -204,6 +259,10 @@ Page({
|
||||
|
||||
async loadAvailableCoupons() {
|
||||
const selectedItems = this.getSelectedItems()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!selectedItems.length) {
|
||||
this.setData({
|
||||
availableCoupons: [],
|
||||
@@ -241,9 +300,17 @@ Page({
|
||||
selectedCouponKey = NO_COUPON_KEY
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (selectedCouponKey === NO_COUPON_KEY) {
|
||||
const bestCoupons = list
|
||||
.sort((left, right) => calculateCouponDiscount(right, subtotalAmount) - calculateCouponDiscount(left, subtotalAmount))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (bestCoupons.length) {
|
||||
selectedCouponKey = bestCoupons[0].key
|
||||
}
|
||||
@@ -263,10 +330,18 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/cart/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBrowseProducts` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBrowseProducts() {
|
||||
navigation.switchTab('/pages/products/index')
|
||||
},
|
||||
@@ -275,6 +350,10 @@ Page({
|
||||
const index = Number(event.currentTarget.dataset.index)
|
||||
const cartItems = this.data.cartItems.slice()
|
||||
const item = cartItems[index]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
@@ -296,11 +375,19 @@ Page({
|
||||
const delta = Number(event.currentTarget.dataset.delta)
|
||||
const cartItems = this.data.cartItems.slice()
|
||||
const item = cartItems[index]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
|
||||
const nextQuantity = Number(item.quantity || 0) + delta
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (nextQuantity < 1 || nextQuantity > 99) {
|
||||
return
|
||||
}
|
||||
@@ -337,6 +424,10 @@ Page({
|
||||
const index = Number(event.currentTarget.dataset.index)
|
||||
const cartItems = this.data.cartItems.slice()
|
||||
const item = cartItems[index]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
@@ -349,6 +440,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
@@ -369,8 +464,16 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenProduct` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenProduct(event) {
|
||||
const productId = event.currentTarget.dataset.productId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
@@ -384,10 +487,18 @@ Page({
|
||||
const index = Number(event.currentTarget.dataset.index)
|
||||
const cartItems = this.data.cartItems.slice()
|
||||
const item = cartItems[index]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item.availableArtists.length) {
|
||||
wx.showToast({
|
||||
title: '当前作品暂时没有可预约美甲师',
|
||||
@@ -398,29 +509,41 @@ Page({
|
||||
|
||||
const tapIndex = await new Promise(resolve => {
|
||||
wx.showActionSheet({
|
||||
itemList: item.availableArtists.map(artist => artist.name),
|
||||
itemList: item.availableArtists.map(artist => artist.roleLabel ? `${artist.name}(${artist.roleLabel})` : artist.name),
|
||||
success: res => resolve(res.tapIndex),
|
||||
fail: () => resolve(-1)
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (tapIndex < 0 || tapIndex >= item.availableArtists.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const artist = item.availableArtists[tapIndex]
|
||||
item.artistId = artist.id
|
||||
item.artistName = artist.name
|
||||
item.artistName = artist.roleLabel ? `${artist.name}(${artist.roleLabel})` : artist.name
|
||||
this.setData({
|
||||
cartItems
|
||||
})
|
||||
this.refreshSummary()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleDateChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleDateChange(event) {
|
||||
const index = Number(event.currentTarget.dataset.index)
|
||||
const cartItems = this.data.cartItems.slice()
|
||||
const item = cartItems[index]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
@@ -433,10 +556,18 @@ Page({
|
||||
this.refreshSummary()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleTimeChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleTimeChange(event) {
|
||||
const index = Number(event.currentTarget.dataset.index)
|
||||
const cartItems = this.data.cartItems.slice()
|
||||
const item = cartItems[index]
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
@@ -449,6 +580,10 @@ Page({
|
||||
this.refreshSummary()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleCouponChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCouponChange(event) {
|
||||
this.setData({
|
||||
selectedCouponKey: event.detail.value
|
||||
@@ -457,12 +592,20 @@ Page({
|
||||
},
|
||||
|
||||
async handleCheckout() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.submittingOrder) {
|
||||
return
|
||||
}
|
||||
|
||||
const selectedItems = this.getSelectedItems()
|
||||
const checkoutIssues = buildCheckoutIssues(this.data.cartItems)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (checkoutIssues.length) {
|
||||
wx.showToast({
|
||||
title: checkoutIssues[0],
|
||||
|
||||
@@ -9,6 +9,10 @@ function getBenefitText(coupon) {
|
||||
return `满 ${coupon.minAmount} 减 ${coupon.reduceAmount}`
|
||||
}
|
||||
|
||||
/**
|
||||
* coupons page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
@@ -24,6 +28,10 @@ Page({
|
||||
]
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadCoupons()
|
||||
},
|
||||
@@ -35,6 +43,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.setData({
|
||||
coupons: [],
|
||||
@@ -74,11 +86,19 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `applyFilter` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
applyFilter(filterValue, sourceCoupons) {
|
||||
const activeFilter = filterValue || 'all'
|
||||
const coupons = Array.isArray(sourceCoupons) ? sourceCoupons : this.data.coupons
|
||||
let filteredCoupons = coupons
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (activeFilter === 'available') {
|
||||
filteredCoupons = coupons.filter(item => Number(item.status) === 1)
|
||||
} else if (activeFilter === 'used') {
|
||||
@@ -93,18 +113,34 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleFilterChange` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleFilterChange(event) {
|
||||
const value = event.currentTarget.dataset.value
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!value || value === this.data.activeFilter) {
|
||||
return
|
||||
}
|
||||
this.applyFilter(value)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/coupons/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ const productApi = require('../../api/product')
|
||||
const shopApi = require('../../api/shop')
|
||||
const userApi = require('../../api/user')
|
||||
|
||||
/**
|
||||
* home page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 96
|
||||
@@ -32,31 +36,52 @@ Page({
|
||||
bannerImages: [],
|
||||
featuredItems: [],
|
||||
popularItems: [],
|
||||
announcements: [],
|
||||
popularPage: 1,
|
||||
pageSize: 6,
|
||||
hasMore: false,
|
||||
popularTotal: 0
|
||||
}),
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad() {
|
||||
this.homeRequestId = 0
|
||||
this.ensureKeyboardSafe()
|
||||
this.loadHomeData()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.ensureKeyboardSafe()
|
||||
this.syncUserState()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.initialized && this.data.isLoggedIn) {
|
||||
this.loadUserProfile()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `onHide` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `onUnload` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
@@ -68,13 +93,25 @@ Page({
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onReachBottom` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onReachBottom() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.hasMore || this.data.loadingMore) {
|
||||
return
|
||||
}
|
||||
this.loadPopularProducts(false)
|
||||
},
|
||||
|
||||
/**
|
||||
* `ensureKeyboardSafe` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 96,
|
||||
@@ -82,6 +119,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `syncUserState` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
syncUserState() {
|
||||
const app = getApp()
|
||||
const userInfo = auth.getStoredUserInfo()
|
||||
@@ -89,6 +130,10 @@ Page({
|
||||
const navTitle = userInfo && String(userInfo.shopName || '').trim()
|
||||
? String(userInfo.shopName).trim()
|
||||
: '游客模式'
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (app) {
|
||||
app.globalData.userInfo = userInfo
|
||||
app.globalData.isLoggedIn = isLoggedIn
|
||||
@@ -118,6 +163,24 @@ Page({
|
||||
} catch (error) {}
|
||||
},
|
||||
|
||||
async loadAnnouncements() {
|
||||
if (!auth.isLoggedIn()) {
|
||||
this.setData({ announcements: [] })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const list = await userApi.listMyAnnouncements()
|
||||
this.setData({
|
||||
announcements: Array.isArray(list) ? list.map(item => ({
|
||||
...item,
|
||||
displayText: `${item.publisherName || '平台'}:${item.content || ''}`
|
||||
})) : []
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ announcements: [] })
|
||||
}
|
||||
},
|
||||
|
||||
async loadHomeData() {
|
||||
const requestId = ++this.homeRequestId
|
||||
this.setData({ loading: true })
|
||||
@@ -126,11 +189,16 @@ Page({
|
||||
try {
|
||||
await Promise.all([
|
||||
this.loadUserProfile(),
|
||||
this.loadAnnouncements(),
|
||||
this.loadBannerImages(requestId),
|
||||
this.loadFeaturedProducts(requestId),
|
||||
this.loadPopularProducts(true, requestId)
|
||||
])
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
initialized: true
|
||||
@@ -142,6 +210,10 @@ Page({
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
@@ -166,6 +238,10 @@ Page({
|
||||
return resolved.filter(item => item.imageUrl)
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
bannerImages: Array.isArray(banners) ? banners : []
|
||||
@@ -183,6 +259,10 @@ Page({
|
||||
return buildProductCards(result && result.list ? result.list : [])
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
featuredItems: Array.isArray(items) ? items : []
|
||||
@@ -203,6 +283,10 @@ Page({
|
||||
tag: '热门'
|
||||
})
|
||||
const cards = await buildProductCards(result && result.list ? result.list : [])
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (currentRequestId !== this.homeRequestId) {
|
||||
return
|
||||
}
|
||||
@@ -215,6 +299,10 @@ Page({
|
||||
hasMore: mergedItems.length < total
|
||||
})
|
||||
} catch (error) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (currentRequestId !== this.homeRequestId) {
|
||||
return
|
||||
}
|
||||
@@ -223,6 +311,10 @@ Page({
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (currentRequestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
loadingMore: false
|
||||
@@ -231,20 +323,36 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchInput(event) {
|
||||
this.setData({
|
||||
searchKeyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchFocus` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchBlur` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchConfirm` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchConfirm() {
|
||||
resetKeyboardSafe(this)
|
||||
navigation.openProducts({
|
||||
@@ -252,8 +360,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBannerTap` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBannerTap(event) {
|
||||
const shopId = event.currentTarget.dataset.shopId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopId) {
|
||||
return
|
||||
}
|
||||
@@ -264,7 +380,15 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProfileTap` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProfileTap() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.isLoggedIn) {
|
||||
navigation.switchTab('/pages/profile/index')
|
||||
return
|
||||
@@ -273,8 +397,16 @@ Page({
|
||||
navigation.openAuth()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProductSelect` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProductSelect(event) {
|
||||
const product = event.detail || {}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product.id) {
|
||||
return
|
||||
}
|
||||
@@ -284,12 +416,20 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSeeAllFeatured` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSeeAllFeatured() {
|
||||
navigation.openProducts({
|
||||
tag: '精选'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSeeAllPopular` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSeeAllPopular() {
|
||||
navigation.openProducts({
|
||||
tag: '热门'
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
<view class="search-btn" bindtap="handleSearchConfirm">搜索</view>
|
||||
</view>
|
||||
|
||||
<swiper wx:if="{{announcements.length}}" class="announcement-strip" autoplay circular vertical interval="2600">
|
||||
<swiper-item wx:for="{{announcements}}" wx:key="id">
|
||||
<view class="announcement-item">{{item.displayText}}</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
<view class="summary-strip">
|
||||
<view class="summary-metric">
|
||||
<text class="summary-label">门店橱窗</text>
|
||||
|
||||
@@ -94,6 +94,26 @@
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.announcement-strip {
|
||||
height: 58rpx;
|
||||
margin-top: 18rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #fff7ed;
|
||||
border: 1rpx solid #fed7aa;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.announcement-item {
|
||||
height: 58rpx;
|
||||
line-height: 58rpx;
|
||||
padding: 0 22rpx;
|
||||
font-size: 24rpx;
|
||||
color: #7c2d12;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.banner-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
const auth = require('../../utils/auth')
|
||||
|
||||
/**
|
||||
* index page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
navTitle: '游客模式'
|
||||
},
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad() {
|
||||
this.syncNavTitle()
|
||||
wx.switchTab({
|
||||
@@ -12,10 +20,18 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.syncNavTitle()
|
||||
},
|
||||
|
||||
/**
|
||||
* `syncNavTitle` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
syncNavTitle() {
|
||||
const userInfo = auth.getStoredUserInfo()
|
||||
const navTitle = userInfo && String(userInfo.shopName || '').trim()
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
const userApi = require('../../api/user')
|
||||
const navigation = require('../../utils/navigation')
|
||||
|
||||
/**
|
||||
* notifications page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
messages: [],
|
||||
unreadCount: 0,
|
||||
detailVisible: false,
|
||||
currentMessage: null
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadMessages()
|
||||
},
|
||||
|
||||
async loadMessages() {
|
||||
if (!navigation.ensureLogin('查看消息通知')) {
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const messages = await userApi.listMyMessages()
|
||||
const list = Array.isArray(messages) ? messages : []
|
||||
this.setData({
|
||||
messages: list,
|
||||
unreadCount: list.filter(item => item.readStatus !== 1).length
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '消息加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
async handleOpenMessage(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
const item = this.data.messages.find(message => String(message.id) === String(id))
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
currentMessage: item,
|
||||
detailVisible: true
|
||||
})
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (item.readStatus !== 1) {
|
||||
try {
|
||||
await userApi.markMessageRead(item.id)
|
||||
await this.loadMessages()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '标记已读失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleCloseDetail` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCloseDetail() {
|
||||
this.setData({
|
||||
detailVisible: false,
|
||||
currentMessage: null
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handlePreviewImage` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handlePreviewImage() {
|
||||
const imageUrl = this.data.currentMessage && this.data.currentMessage.imageUrl
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!imageUrl) {
|
||||
return
|
||||
}
|
||||
wx.previewImage({
|
||||
current: imageUrl,
|
||||
urls: [imageUrl]
|
||||
})
|
||||
},
|
||||
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationStyle": "custom",
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<navigation-bar title="消息通知" showBack="{{true}}" fallbackPath="/pages/profile/index" color="#2d2430" background="#fff7f8"></navigation-bar>
|
||||
|
||||
<view class="notifications-page">
|
||||
<view class="summary-card">
|
||||
<view class="summary-title">消息通知</view>
|
||||
<view class="summary-desc">{{unreadCount}} 条未读消息</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{messages.length}}" class="message-list">
|
||||
<view
|
||||
wx:for="{{messages}}"
|
||||
wx:key="id"
|
||||
class="message-item {{item.readStatus === 1 ? '' : 'unread'}}"
|
||||
data-id="{{item.id}}"
|
||||
bindtap="handleOpenMessage"
|
||||
>
|
||||
<view class="message-dot"></view>
|
||||
<view class="message-copy">
|
||||
<view class="message-title">{{item.title}}</view>
|
||||
<view class="message-meta">{{item.publisherName || '系统消息'}} · {{item.publishTime || item.createTime}}</view>
|
||||
<view wx:if="{{item.imageUrl}}" class="message-badge">含图片</view>
|
||||
</view>
|
||||
<view class="message-arrow">></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="empty-card">
|
||||
暂无消息
|
||||
</view>
|
||||
|
||||
<view wx:if="{{detailVisible && currentMessage}}" class="detail-mask" bindtap="handleCloseDetail">
|
||||
<view class="detail-panel" catchtap="noop">
|
||||
<view class="detail-header">
|
||||
<view>
|
||||
<view class="detail-title">{{currentMessage.title}}</view>
|
||||
<view class="detail-meta">{{currentMessage.publisherName || '系统消息'}} · {{currentMessage.publishTime || currentMessage.createTime}}</view>
|
||||
</view>
|
||||
<button class="detail-close" size="mini" bindtap="handleCloseDetail">关闭</button>
|
||||
</view>
|
||||
<view wx:if="{{currentMessage.content}}" class="detail-content">{{currentMessage.content}}</view>
|
||||
<image
|
||||
wx:if="{{currentMessage.imageUrl}}"
|
||||
class="detail-image"
|
||||
src="{{currentMessage.imageUrl}}"
|
||||
mode="aspectFit"
|
||||
bindtap="handlePreviewImage"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,152 @@
|
||||
.notifications-page {
|
||||
min-height: 100vh;
|
||||
padding: 176rpx 28rpx 40rpx;
|
||||
background: #fff7f8;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.summary-card,
|
||||
.message-item,
|
||||
.empty-card {
|
||||
border-radius: 18rpx;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 16rpx 40rpx rgba(150, 82, 105, 0.08);
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
padding: 34rpx;
|
||||
margin-bottom: 22rpx;
|
||||
}
|
||||
|
||||
.summary-title {
|
||||
color: #2d2430;
|
||||
font-size: 38rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.summary-desc {
|
||||
margin-top: 8rpx;
|
||||
color: #927f88;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 28rpx;
|
||||
}
|
||||
|
||||
.message-dot {
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
border-radius: 50%;
|
||||
background: #d7c9cf;
|
||||
}
|
||||
|
||||
.message-item.unread .message-dot {
|
||||
background: #ff5c8a;
|
||||
}
|
||||
|
||||
.message-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.message-title {
|
||||
color: #2d2430;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.message-meta {
|
||||
margin-top: 8rpx;
|
||||
color: #9b8d94;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.message-badge {
|
||||
display: inline-block;
|
||||
margin-top: 10rpx;
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #fff0f4;
|
||||
color: #d74270;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.message-arrow {
|
||||
color: #c3aab4;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
padding: 60rpx;
|
||||
color: #9b8d94;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.detail-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
background: rgba(26, 18, 24, 0.45);
|
||||
}
|
||||
|
||||
.detail-panel {
|
||||
width: 100%;
|
||||
max-height: 82vh;
|
||||
padding: 34rpx 30rpx 46rpx;
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
color: #2d2430;
|
||||
font-size: 34rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.detail-meta {
|
||||
margin-top: 8rpx;
|
||||
color: #9b8d94;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.detail-close {
|
||||
margin: 0;
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
margin-top: 28rpx;
|
||||
color: #4b4048;
|
||||
font-size: 28rpx;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.detail-image {
|
||||
width: 100%;
|
||||
min-height: 320rpx;
|
||||
max-height: 760rpx;
|
||||
margin-top: 24rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #fff7f8;
|
||||
}
|
||||
@@ -6,6 +6,10 @@ const { resolveLegacyImage } = require('../../utils/file')
|
||||
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* orders page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
@@ -13,6 +17,10 @@ Page({
|
||||
orders: []
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadOrders()
|
||||
},
|
||||
@@ -24,6 +32,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.setData({
|
||||
orders: [],
|
||||
@@ -39,6 +51,7 @@ Page({
|
||||
...order,
|
||||
statusText: getOrderStatusText(order),
|
||||
statusClass: getOrderStatusClass(order),
|
||||
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
||||
actualAmountText: `\u00a5${formatPrice(order.actualAmount)}`,
|
||||
items: await Promise.all((order.items || []).map(async item => ({
|
||||
...item,
|
||||
@@ -66,16 +79,28 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/orders/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
},
|
||||
|
||||
async handleCancelOrder(event) {
|
||||
const orderId = event.currentTarget.dataset.orderId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!orderId) {
|
||||
return
|
||||
}
|
||||
@@ -90,6 +115,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
</view>
|
||||
<text class="order-status {{item.statusClass}}">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view wx:if="{{item.shopNameText}}" class="order-shop">{{item.shopNameText}}</view>
|
||||
|
||||
<view wx:for="{{item.items}}" wx:key="id" wx:for-item="orderItem" class="order-item">
|
||||
<image class="order-thumb" src="{{orderItem.productImageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
|
||||
|
||||
@@ -23,6 +23,13 @@
|
||||
border-bottom: 2rpx solid #f3e7eb;
|
||||
}
|
||||
|
||||
.order-shop {
|
||||
margin: 14rpx 0 0;
|
||||
color: #8f6e7a;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.order-head-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
@@ -13,11 +13,19 @@ const { formatPrice, getProductTitle, splitCsv } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
function parseTimeRange(businessHours) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!businessHours) {
|
||||
return null
|
||||
}
|
||||
|
||||
const matched = String(businessHours).replace(/\s+/g, '').match(/(\d{1,2}:\d{2}).*?(\d{1,2}:\d{2})/)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!matched) {
|
||||
return null
|
||||
}
|
||||
@@ -30,6 +38,10 @@ function parseTimeRange(businessHours) {
|
||||
|
||||
function estimateEarliestBookable(businessHours) {
|
||||
const range = parseTimeRange(businessHours)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!range) {
|
||||
return businessHours || '以门店安排为准'
|
||||
}
|
||||
@@ -43,10 +55,18 @@ function estimateEarliestBookable(businessHours) {
|
||||
openTime.setHours(startParts[0], startParts[1], 0, 0)
|
||||
closeTime.setHours(endParts[0], endParts[1], 0, 0)
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (next <= openTime) {
|
||||
return `今天 ${range.start}`
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (next >= closeTime) {
|
||||
return `明天 ${range.start}`
|
||||
}
|
||||
@@ -58,6 +78,10 @@ function estimateEarliestBookable(businessHours) {
|
||||
return `${month}-${date} ${hour}:${minute}`
|
||||
}
|
||||
|
||||
/**
|
||||
* product-detail page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: true,
|
||||
@@ -75,6 +99,10 @@ Page({
|
||||
earliestBookableText: '以门店安排为准'
|
||||
},
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
productId: options && options.id ? options.id : ''
|
||||
@@ -90,6 +118,10 @@ Page({
|
||||
|
||||
async loadProductDetail() {
|
||||
const productId = this.data.productId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
@@ -148,6 +180,10 @@ Page({
|
||||
|
||||
async loadInteractionStatus() {
|
||||
const product = this.data.product
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product || !product.id) {
|
||||
return
|
||||
}
|
||||
@@ -166,6 +202,10 @@ Page({
|
||||
|
||||
async loadComments() {
|
||||
const product = this.data.product
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product || !product.id) {
|
||||
this.setData({ comments: [] })
|
||||
return
|
||||
@@ -180,12 +220,24 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/products/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handlePreviewImage` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handlePreviewImage(event) {
|
||||
const current = event.currentTarget.dataset.url
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!current) {
|
||||
return
|
||||
}
|
||||
@@ -196,8 +248,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenShop` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenShop() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopInfo || !shopInfo.id) {
|
||||
return
|
||||
}
|
||||
@@ -217,6 +277,10 @@ Page({
|
||||
try {
|
||||
await actionGuard.run(this, `wishlist:toggle:${product.id}`, async () => {
|
||||
const nextFavorite = !this.data.isFavorite
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.isFavorite) {
|
||||
await runWithLoading(() => wishlistApi.removeFromWishlist(product.id))
|
||||
product.collectCount = Math.max(0, Number(product.collectCount || 0) - 1)
|
||||
@@ -257,6 +321,10 @@ Page({
|
||||
try {
|
||||
await actionGuard.run(this, `like:toggle:${product.id}`, async () => {
|
||||
const nextLiked = !this.data.isLiked
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.isLiked) {
|
||||
await runWithLoading(() => productLikeApi.unlikeProduct(product.id))
|
||||
product.likeCount = Math.max(0, Number(product.likeCount || 0) - 1)
|
||||
@@ -346,12 +414,20 @@ Page({
|
||||
}
|
||||
,
|
||||
|
||||
/**
|
||||
* `handleCommentInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCommentInput(event) {
|
||||
this.setData({
|
||||
commentText: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleReply` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleReply(event) {
|
||||
const comment = event.currentTarget.dataset.comment
|
||||
this.setData({
|
||||
@@ -365,6 +441,10 @@ Page({
|
||||
if (!product || !product.id || !navigation.ensureLogin('发表评论')) {
|
||||
return
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!content) {
|
||||
wx.showToast({ title: '请输入评论内容', icon: 'none' })
|
||||
return
|
||||
|
||||
@@ -21,6 +21,10 @@ const ALL_CATEGORY = '\u5168\u90e8'
|
||||
const FILTER_BUSY_MESSAGE = '\u7b5b\u9009\u5904\u7406\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u64cd\u4f5c'
|
||||
const CART_BUSY_MESSAGE = '\u8d2d\u7269\u8f66\u5904\u7406\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u64cd\u4f5c'
|
||||
|
||||
/**
|
||||
* products page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 96
|
||||
@@ -39,6 +43,10 @@ Page({
|
||||
hasMore: false
|
||||
}),
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.filterRequestId = 0
|
||||
this.ensureKeyboardSafe()
|
||||
@@ -51,6 +59,10 @@ Page({
|
||||
const pendingFilter = app && app.globalData ? app.globalData.pendingProductFilter : null
|
||||
|
||||
if (this.data.initialized && pendingFilter && (pendingFilter.keyword || pendingFilter.tag)) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (app && app.globalData) {
|
||||
app.globalData.pendingProductFilter = null
|
||||
}
|
||||
@@ -58,16 +70,28 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.initialized) {
|
||||
await this.syncProductCartState()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `onHide` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `onUnload` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
@@ -78,13 +102,25 @@ Page({
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onReachBottom` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onReachBottom() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.hasMore || this.data.loadingMore) {
|
||||
return
|
||||
}
|
||||
this.loadProducts(false)
|
||||
},
|
||||
|
||||
/**
|
||||
* `ensureKeyboardSafe` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 96,
|
||||
@@ -127,6 +163,10 @@ Page({
|
||||
const app = getApp()
|
||||
const pendingFilter = app && app.globalData ? app.globalData.pendingProductFilter : null
|
||||
if (pendingFilter && (pendingFilter.keyword || pendingFilter.tag)) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (app && app.globalData) {
|
||||
app.globalData.pendingProductFilter = null
|
||||
}
|
||||
@@ -169,6 +209,10 @@ Page({
|
||||
})
|
||||
const cards = await buildProductCards(result && result.list ? result.list : [])
|
||||
const displayCards = await this.attachCartState(cards)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId !== this.filterRequestId) {
|
||||
return
|
||||
}
|
||||
@@ -183,9 +227,17 @@ Page({
|
||||
filterSummaryText: this.buildFilterSummary(keyword, tag, total)
|
||||
})
|
||||
} catch (error) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId !== this.filterRequestId) {
|
||||
return
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (reset) {
|
||||
this.setData({
|
||||
products: [],
|
||||
@@ -199,6 +251,10 @@ Page({
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.filterRequestId) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
@@ -208,11 +264,23 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `buildFilterSummary` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
buildFilterSummary(keyword, tag, total) {
|
||||
const chips = []
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (tag) {
|
||||
chips.push(tag)
|
||||
}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (keyword) {
|
||||
chips.push(`\u641c\u7d22\uff1a${keyword}`)
|
||||
}
|
||||
@@ -220,6 +288,10 @@ Page({
|
||||
return chips.join(' \u00b7 ')
|
||||
},
|
||||
|
||||
/**
|
||||
* `normalizeId` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
},
|
||||
@@ -250,6 +322,10 @@ Page({
|
||||
return this.markCardsInCart(cards, idSet)
|
||||
},
|
||||
|
||||
/**
|
||||
* `markCardsInCart` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
markCardsInCart(cards, idSet) {
|
||||
const productIdSet = idSet || new Set()
|
||||
return (Array.isArray(cards) ? cards : []).map(item => ({
|
||||
@@ -265,8 +341,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `markProductInCart` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
markProductInCart(productId) {
|
||||
const normalizedId = this.normalizeId(productId)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!normalizedId) {
|
||||
return
|
||||
}
|
||||
@@ -286,16 +370,28 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchInput(event) {
|
||||
this.setData({
|
||||
searchKeyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchFocus` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchBlur` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
@@ -372,8 +468,16 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProductSelect` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProductSelect(event) {
|
||||
const product = event.detail || {}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product.id) {
|
||||
return
|
||||
}
|
||||
@@ -386,6 +490,10 @@ Page({
|
||||
async handleQuickAdd(event) {
|
||||
const product = event.detail || {}
|
||||
const productId = this.normalizeId(product.id)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ const navigation = require('../../utils/navigation')
|
||||
const { DEFAULT_AVATAR } = require('../../utils/config')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* profile page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
isLoggedIn: false,
|
||||
@@ -18,9 +22,14 @@ Page({
|
||||
orderCount: 0,
|
||||
couponCount: 0,
|
||||
wishlistCount: 0,
|
||||
unreadMessageCount: 0,
|
||||
defaultAvatar: DEFAULT_AVATAR
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadProfile()
|
||||
},
|
||||
@@ -34,6 +43,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.setData({
|
||||
userInfo: null,
|
||||
@@ -46,11 +59,12 @@ Page({
|
||||
}
|
||||
|
||||
try {
|
||||
const [userInfo, orders, coupons, wishlist] = await Promise.all([
|
||||
const [userInfo, orders, coupons, wishlist, unreadMessages] = await Promise.all([
|
||||
userApi.getUserInfo(),
|
||||
orderApi.getOrderList(),
|
||||
couponApi.listUserCoupons(),
|
||||
wishlistApi.getWishlist()
|
||||
wishlistApi.getWishlist(),
|
||||
userApi.getMyUnreadMessageCount()
|
||||
])
|
||||
|
||||
getApp().refreshUserInfo(userInfo)
|
||||
@@ -58,8 +72,10 @@ Page({
|
||||
userInfo,
|
||||
orderCount: Array.isArray(orders) ? orders.length : 0,
|
||||
couponCount: Array.isArray(coupons) ? coupons.length : 0,
|
||||
wishlistCount: Array.isArray(wishlist) ? wishlist.length : 0
|
||||
wishlistCount: Array.isArray(wishlist) ? wishlist.length : 0,
|
||||
unreadMessageCount: Number((unreadMessages && unreadMessages.unreadCount) || 0)
|
||||
})
|
||||
await this.checkPopupMessages()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '\u4e2a\u4eba\u4e2d\u5fc3\u52a0\u8f7d\u5931\u8d25',
|
||||
@@ -72,11 +88,23 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/profile/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenSettings` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenSettings() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.isLoggedIn) {
|
||||
this.handleOpenAuth()
|
||||
return
|
||||
@@ -84,6 +112,10 @@ Page({
|
||||
navigation.navigate('/pages/settings/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenOrders` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenOrders() {
|
||||
if (!navigation.ensureLogin('\u67e5\u770b\u8ba2\u5355')) {
|
||||
return
|
||||
@@ -91,6 +123,10 @@ Page({
|
||||
navigation.navigate('/pages/orders/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenWishlist` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenWishlist() {
|
||||
if (!navigation.ensureLogin('\u67e5\u770b\u6536\u85cf')) {
|
||||
return
|
||||
@@ -98,6 +134,10 @@ Page({
|
||||
navigation.navigate('/pages/wishlist/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenCoupons` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenCoupons() {
|
||||
if (!navigation.ensureLogin('\u67e5\u770b\u4f18\u60e0\u5238')) {
|
||||
return
|
||||
@@ -105,6 +145,62 @@ Page({
|
||||
navigation.navigate('/pages/coupons/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenVipCenter` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenVipCenter() {
|
||||
if (!navigation.ensureLogin('查看 VIP 中心')) {
|
||||
return
|
||||
}
|
||||
navigation.navigate('/pages/vip-center/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenNotifications` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenNotifications() {
|
||||
if (!navigation.ensureLogin('查看消息通知')) {
|
||||
return
|
||||
}
|
||||
navigation.navigate('/pages/notifications/index')
|
||||
},
|
||||
|
||||
async checkPopupMessages() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this._checkingPopupMessages) {
|
||||
return
|
||||
}
|
||||
this._checkingPopupMessages = true
|
||||
try {
|
||||
const messages = await userApi.listMyPopupMessages()
|
||||
/**
|
||||
* `for` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
for (const item of messages || []) {
|
||||
await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: item.title || '消息通知',
|
||||
content: item.content || '',
|
||||
showCancel: false,
|
||||
confirmText: '我知道了',
|
||||
complete: resolve
|
||||
})
|
||||
})
|
||||
await userApi.markMessagePopupShown(item.id)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载待弹窗消息失败', error)
|
||||
} finally {
|
||||
this._checkingPopupMessages = false
|
||||
}
|
||||
},
|
||||
|
||||
async handleSwitchShop() {
|
||||
if (!navigation.ensureLogin('\u5207\u6362\u95e8\u5e97')) {
|
||||
return
|
||||
@@ -114,6 +210,10 @@ Page({
|
||||
const shopIds = userInfo && Array.isArray(userInfo.shopIds) ? userInfo.shopIds : []
|
||||
const shopNames = userInfo && Array.isArray(userInfo.shopNames) ? userInfo.shopNames : []
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopIds.length) {
|
||||
wx.showToast({
|
||||
title: '\u5f53\u524d\u8d26\u53f7\u8fd8\u6ca1\u6709\u53ef\u7528\u95e8\u5e97',
|
||||
@@ -122,6 +222,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (shopIds.length === 1) {
|
||||
navigation.navigate('/pages/shop-detail/index', {
|
||||
id: shopIds[0],
|
||||
@@ -140,6 +244,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (selection < 0 || selection >= shopIds.length) {
|
||||
return
|
||||
}
|
||||
@@ -168,6 +276,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleLogout() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.isLoggedIn) {
|
||||
this.handleOpenAuth()
|
||||
return
|
||||
@@ -183,6 +295,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
@@ -209,10 +325,18 @@ Page({
|
||||
|
||||
async handleAvatarError() {
|
||||
const currentAvatar = this.data.userInfo && this.data.userInfo.avatar
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!currentAvatar) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this._avatarReloadSource === currentAvatar) {
|
||||
this.setData({
|
||||
'userInfo.avatar': ''
|
||||
@@ -225,6 +349,10 @@ Page({
|
||||
try {
|
||||
const userInfo = await userApi.getUserInfo()
|
||||
getApp().refreshUserInfo(userInfo)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!userInfo || !userInfo.avatar || userInfo.avatar === currentAvatar) {
|
||||
this.setData({
|
||||
'userInfo.avatar': ''
|
||||
|
||||
@@ -67,6 +67,15 @@
|
||||
<text>我的优惠券</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
<view class="menu-item" bindtap="handleOpenVipCenter">
|
||||
<text>VIP 中心</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
<view class="menu-item" bindtap="handleOpenNotifications">
|
||||
<text>消息通知</text>
|
||||
<text wx:if="{{unreadMessageCount > 0}}" class="menu-badge">{{unreadMessageCount}}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
<view class="menu-item" bindtap="handleOpenSettings">
|
||||
<text>设置中心</text>
|
||||
<text class="menu-arrow">></text>
|
||||
|
||||
@@ -161,6 +161,23 @@
|
||||
color: #c3aab4;
|
||||
}
|
||||
|
||||
.menu-badge {
|
||||
margin-left: auto;
|
||||
min-width: 36rpx;
|
||||
height: 36rpx;
|
||||
padding: 0 10rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #ff5c8a;
|
||||
color: #ffffff;
|
||||
font-size: 22rpx;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.menu-badge + .menu-arrow {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.logout-item {
|
||||
color: #d5536f;
|
||||
font-weight: 700;
|
||||
|
||||
@@ -18,6 +18,10 @@ const phoneRegex = /^1[3-9]\d{9}$/
|
||||
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/
|
||||
const SETTINGS_DRAFT_KEY = 'user-settings'
|
||||
|
||||
/**
|
||||
* settings page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 108
|
||||
@@ -53,15 +57,27 @@ Page({
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad() {
|
||||
this.ensureKeyboardSafe()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.ensureKeyboardSafe()
|
||||
this.loadSettings()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onHide` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
@@ -69,6 +85,10 @@ Page({
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `onUnload` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
@@ -76,6 +96,10 @@ Page({
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `ensureKeyboardSafe` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 108,
|
||||
@@ -83,21 +107,41 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleKeyboardFocus` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleKeyboardFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleKeyboardBlur` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleKeyboardBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `clearCountdown` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
clearCountdown() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.countdownTimer) {
|
||||
clearInterval(this.countdownTimer)
|
||||
this.countdownTimer = null
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `resetSecurityForms` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
resetSecurityForms() {
|
||||
this.setData({
|
||||
bindPhoneForm: {
|
||||
@@ -116,8 +160,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `restoreDraftValues` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
restoreDraftValues() {
|
||||
const draft = getDraftValue(SETTINGS_DRAFT_KEY, null)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!draft || typeof draft !== 'object') {
|
||||
return
|
||||
}
|
||||
@@ -131,6 +183,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `scheduleSettingsDraft` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
scheduleSettingsDraft() {
|
||||
scheduleDraftSave(this, SETTINGS_DRAFT_KEY, () => ({
|
||||
activeSecurityPanel: this.data.activeSecurityPanel,
|
||||
@@ -147,6 +203,10 @@ Page({
|
||||
}))
|
||||
},
|
||||
|
||||
/**
|
||||
* `startCountdown` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
startCountdown() {
|
||||
this.clearCountdown()
|
||||
this.setData({
|
||||
@@ -155,6 +215,10 @@ Page({
|
||||
|
||||
this.countdownTimer = setInterval(() => {
|
||||
const next = this.data.countdown - 1
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (next <= 0) {
|
||||
this.clearCountdown()
|
||||
this.setData({
|
||||
@@ -177,6 +241,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.clearCountdown()
|
||||
this.setData({
|
||||
@@ -209,14 +277,26 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/settings/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleFormInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleFormInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -225,26 +305,46 @@ Page({
|
||||
this.scheduleSettingsDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBindPhoneInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBindPhoneInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
[`bindPhoneForm.${field}`]: event.detail.value
|
||||
})
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (field === 'phone') {
|
||||
this.scheduleSettingsDraft()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleChangePhoneInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleChangePhoneInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
[`changePhoneForm.${field}`]: event.detail.value
|
||||
})
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (field === 'newPhone') {
|
||||
this.scheduleSettingsDraft()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handlePasswordInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handlePasswordInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -252,6 +352,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleToggleSecurityPanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleToggleSecurityPanel(event) {
|
||||
const panel = event.currentTarget.dataset.panel
|
||||
const nextPanel = this.data.activeSecurityPanel === panel ? '' : panel
|
||||
@@ -265,6 +369,10 @@ Page({
|
||||
this.scheduleSettingsDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleCloseSecurityPanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCloseSecurityPanel() {
|
||||
resetKeyboardSafe(this)
|
||||
this.resetSecurityForms()
|
||||
@@ -312,7 +420,15 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleChooseAvatar` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleChooseAvatar() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.uploadingAvatar) {
|
||||
return
|
||||
}
|
||||
@@ -323,6 +439,10 @@ Page({
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async res => {
|
||||
const filePath = Array.isArray(res.tempFilePaths) ? res.tempFilePaths[0] : ''
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
@@ -353,6 +473,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleDeleteAvatar() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.userInfo || !this.data.userInfo.avatar) {
|
||||
return
|
||||
}
|
||||
@@ -365,6 +489,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
@@ -395,6 +523,10 @@ Page({
|
||||
const shopIds = userInfo && Array.isArray(userInfo.shopIds) ? userInfo.shopIds : []
|
||||
const shopNames = userInfo && Array.isArray(userInfo.shopNames) ? userInfo.shopNames : []
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopIds.length) {
|
||||
wx.showToast({
|
||||
title: '当前账号还没有可用门店',
|
||||
@@ -403,6 +535,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (shopIds.length === 1) {
|
||||
navigation.navigate('/pages/shop-detail/index', {
|
||||
id: shopIds[0],
|
||||
@@ -419,6 +555,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (selection < 0 || selection >= shopIds.length) {
|
||||
return
|
||||
}
|
||||
@@ -442,6 +582,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleSendBindPhoneCode() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.countdown > 0) {
|
||||
return
|
||||
}
|
||||
@@ -456,7 +600,10 @@ Page({
|
||||
}
|
||||
|
||||
try {
|
||||
await runWithLoading(() => userApi.sendVerificationCode({ phone }))
|
||||
await runWithLoading(() => userApi.sendVerificationCode({
|
||||
phone,
|
||||
sceneCode: 'USER_BIND_PHONE_SMS_CODE'
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
@@ -482,6 +629,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!verificationCode) {
|
||||
wx.showToast({
|
||||
title: '请输入验证码',
|
||||
@@ -519,6 +670,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleSendChangePhoneCode() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.countdown > 0) {
|
||||
return
|
||||
}
|
||||
@@ -533,7 +688,10 @@ Page({
|
||||
}
|
||||
|
||||
try {
|
||||
await runWithLoading(() => userApi.sendVerificationCode({ phone: newPhone }))
|
||||
await runWithLoading(() => userApi.sendVerificationCode({
|
||||
phone: newPhone,
|
||||
sceneCode: 'USER_CHANGE_PHONE_SMS_CODE'
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
@@ -553,6 +711,10 @@ Page({
|
||||
const newPhone = String(this.data.changePhoneForm.newPhone || '').trim()
|
||||
const verificationCode = String(this.data.changePhoneForm.verificationCode || '').trim()
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!oldPhone) {
|
||||
wx.showToast({
|
||||
title: '请先绑定手机号',
|
||||
@@ -569,6 +731,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!verificationCode) {
|
||||
wx.showToast({
|
||||
title: '请输入验证码',
|
||||
@@ -607,12 +773,20 @@ Page({
|
||||
},
|
||||
|
||||
async handleSendPasswordCode() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.countdown > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const userInfo = this.data.userInfo || {}
|
||||
const phone = String(userInfo.phone || '').trim()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!phone) {
|
||||
wx.showToast({
|
||||
title: '请先绑定手机号',
|
||||
@@ -622,7 +796,10 @@ Page({
|
||||
}
|
||||
|
||||
try {
|
||||
await runWithLoading(() => authApi.sendVerificationCode({ phone }))
|
||||
await runWithLoading(() => authApi.sendVerificationCode({
|
||||
phone,
|
||||
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
|
||||
}))
|
||||
wx.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
@@ -642,6 +819,10 @@ Page({
|
||||
const confirmPassword = String(this.data.passwordForm.confirmPassword || '')
|
||||
const userInfo = this.data.userInfo || {}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!userInfo.phone) {
|
||||
wx.showToast({
|
||||
title: '请先绑定手机号',
|
||||
@@ -650,6 +831,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!verificationCode) {
|
||||
wx.showToast({
|
||||
title: '请输入验证码',
|
||||
@@ -666,6 +851,10 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (password !== confirmPassword) {
|
||||
wx.showToast({
|
||||
title: '两次输入的密码不一致',
|
||||
@@ -704,6 +893,10 @@ Page({
|
||||
},
|
||||
|
||||
async handleDeactivateAccount() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.deactivating) {
|
||||
return
|
||||
}
|
||||
@@ -717,6 +910,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
@@ -757,6 +954,10 @@ Page({
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
@@ -778,10 +979,18 @@ Page({
|
||||
|
||||
async handleAvatarError() {
|
||||
const currentAvatar = this.data.userInfo && this.data.userInfo.avatar
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!currentAvatar) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this._avatarReloadSource === currentAvatar) {
|
||||
this.setData({
|
||||
'userInfo.avatar': ''
|
||||
@@ -794,6 +1003,10 @@ Page({
|
||||
try {
|
||||
const userInfo = await userApi.getUserInfo()
|
||||
getApp().refreshUserInfo(userInfo)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!userInfo || !userInfo.avatar || userInfo.avatar === currentAvatar) {
|
||||
this.setData({
|
||||
'userInfo.avatar': ''
|
||||
|
||||
@@ -3,6 +3,10 @@ const navigation = require('../../utils/navigation')
|
||||
const { resolveImageList } = require('../../utils/file')
|
||||
const { DEFAULT_SHOP_IMAGE } = require('../../utils/config')
|
||||
|
||||
/**
|
||||
* shop-detail page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: true,
|
||||
@@ -10,9 +14,14 @@ Page({
|
||||
shopId: '',
|
||||
returnTo: '/pages/home/index',
|
||||
shopInfo: null,
|
||||
distanceText: '',
|
||||
shopImages: []
|
||||
},
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
shopId: options && options.id ? options.id : '',
|
||||
@@ -27,6 +36,10 @@ Page({
|
||||
},
|
||||
|
||||
async loadShopDetail() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.shopId) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
@@ -45,8 +58,10 @@ Page({
|
||||
const shopImages = await resolveImageList(shopInfo.imageFileIds || shopInfo.coverImageFileId, DEFAULT_SHOP_IMAGE)
|
||||
this.setData({
|
||||
shopInfo,
|
||||
shopImages
|
||||
shopImages,
|
||||
distanceText: ''
|
||||
})
|
||||
this.loadCurrentDistance()
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
loadError: error.message || '门店详情加载失败'
|
||||
@@ -58,12 +73,24 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack(this.data.returnTo || '/pages/home/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handlePreviewImage` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handlePreviewImage(event) {
|
||||
const url = event.currentTarget.dataset.url
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!url) {
|
||||
return
|
||||
}
|
||||
@@ -74,8 +101,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleCopyName` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCopyName() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopInfo || !shopInfo.shopName) {
|
||||
return
|
||||
}
|
||||
@@ -85,8 +120,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleCopyAddress` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleCopyAddress() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopInfo || !shopInfo.address) {
|
||||
return
|
||||
}
|
||||
@@ -94,5 +137,73 @@ Page({
|
||||
wx.setClipboardData({
|
||||
data: shopInfo.address
|
||||
})
|
||||
},
|
||||
|
||||
handleOpenLocation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.latitude || !shopInfo.longitude) {
|
||||
wx.showToast({
|
||||
title: '店铺暂未设置地图位置',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
wx.openLocation({
|
||||
latitude: Number(shopInfo.latitude),
|
||||
longitude: Number(shopInfo.longitude),
|
||||
name: shopInfo.shopName || '店铺位置',
|
||||
address: shopInfo.address || '',
|
||||
scale: 16
|
||||
})
|
||||
},
|
||||
|
||||
handleOpenAmapNavigation() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
const amapUrl = shopInfo && shopInfo.navigationUrls && shopInfo.navigationUrls.AMAP
|
||||
if (!amapUrl) {
|
||||
wx.showToast({
|
||||
title: '店铺暂未设置地图位置',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.setClipboardData({
|
||||
data: amapUrl,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '高德导航链接已复制',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
loadCurrentDistance() {
|
||||
const shopInfo = this.data.shopInfo
|
||||
if (!shopInfo || !shopInfo.latitude || !shopInfo.longitude || typeof wx.getLocation !== 'function') {
|
||||
return
|
||||
}
|
||||
wx.getLocation({
|
||||
type: 'gcj02',
|
||||
success: (res) => {
|
||||
this.setData({
|
||||
distanceText: this.formatDistance(res.latitude, res.longitude, Number(shopInfo.latitude), Number(shopInfo.longitude))
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
formatDistance(currentLat, currentLng, shopLat, shopLng) {
|
||||
if (![currentLat, currentLng, shopLat, shopLng].every(Number.isFinite)) {
|
||||
return ''
|
||||
}
|
||||
const toRad = value => value * Math.PI / 180
|
||||
const earthRadius = 6371000
|
||||
const dLat = toRad(shopLat - currentLat)
|
||||
const dLng = toRad(shopLng - currentLng)
|
||||
const a = Math.sin(dLat / 2) ** 2 + Math.cos(toRad(currentLat)) * Math.cos(toRad(shopLat)) * Math.sin(dLng / 2) ** 2
|
||||
const meters = 2 * earthRadius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
|
||||
return meters >= 1000 ? `距你约 ${(meters / 1000).toFixed(1)} km` : `距你约 ${Math.round(meters)} m`
|
||||
}
|
||||
})
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<view class="section-kicker">门店详情</view>
|
||||
<view class="shop-title">{{shopInfo.shopName}}</view>
|
||||
<view class="shop-address" bindtap="handleCopyAddress">{{shopInfo.address || '门店地址待补充'}}</view>
|
||||
<view wx:if="{{distanceText}}" class="shop-distance">{{distanceText}}</view>
|
||||
|
||||
<view class="summary-strip shop-summary">
|
||||
<view class="summary-metric">
|
||||
@@ -47,6 +48,11 @@
|
||||
<view class="ghost-btn" bindtap="handleCopyName">复制门店名</view>
|
||||
<view class="ghost-btn" bindtap="handleCopyAddress">复制地址</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{shopInfo.longitude && shopInfo.latitude}}" class="map-row">
|
||||
<view class="primary-btn map-btn" bindtap="handleOpenLocation">查看地图位置</view>
|
||||
<view class="ghost-btn map-btn" bindtap="handleOpenAmapNavigation">复制高德导航链接</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-block">
|
||||
|
||||
@@ -46,6 +46,13 @@
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.shop-distance {
|
||||
margin-top: 8rpx;
|
||||
color: #8f6e7a;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.shop-summary {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
@@ -77,6 +84,17 @@
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
|
||||
.map-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.map-btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.gallery-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
const userApi = require('../../api/user')
|
||||
const navigation = require('../../utils/navigation')
|
||||
|
||||
function money(value) {
|
||||
return Number(value || 0).toFixed(2)
|
||||
}
|
||||
|
||||
function formatTime(value) {
|
||||
return value ? String(value).replace('T', ' ').slice(0, 16) : '--'
|
||||
}
|
||||
|
||||
function sceneText(scene) {
|
||||
const map = {
|
||||
MANUAL_RECHARGE: '手工充值',
|
||||
MANUAL_DEDUCT: '手工扣减',
|
||||
ORDER_PAY: '订单消费',
|
||||
ORDER_REFUND: '订单退款',
|
||||
RECHARGE: '充值',
|
||||
CONSUME: '消费'
|
||||
}
|
||||
return map[scene] || scene || '余额变动'
|
||||
}
|
||||
|
||||
/**
|
||||
* vip-center page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
asset: {
|
||||
vipLevel: '普通',
|
||||
balanceText: '0.00',
|
||||
totalRechargeText: '0.00',
|
||||
lastRechargeText: '--',
|
||||
vipStartText: '--',
|
||||
manualOverride: false
|
||||
},
|
||||
history: [],
|
||||
rechargePlans: [],
|
||||
rechargePanelVisible: false
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('查看 VIP 中心')) {
|
||||
return
|
||||
}
|
||||
this.loadData()
|
||||
},
|
||||
|
||||
async loadData() {
|
||||
try {
|
||||
const [asset, history, plans] = await Promise.all([
|
||||
userApi.getMyAsset(),
|
||||
userApi.getMyBalanceHistory(),
|
||||
userApi.listMyVipRechargePlans().catch(() => [])
|
||||
])
|
||||
this.setData({
|
||||
asset: {
|
||||
...asset,
|
||||
balanceText: money(asset && asset.balance),
|
||||
totalRechargeText: money(asset && asset.totalRechargeAmount),
|
||||
lastRechargeText: formatTime(asset && asset.lastRechargeTime),
|
||||
vipStartText: formatTime(asset && asset.vipStartTime)
|
||||
},
|
||||
history: (Array.isArray(history) ? history : []).map(item => {
|
||||
const amountNumber = Number(item.amount || 0)
|
||||
return {
|
||||
...item,
|
||||
amountNumber,
|
||||
amountText: `${amountNumber > 0 ? '+' : ''}¥${money(amountNumber)}`,
|
||||
sceneText: sceneText(item.changeScene || item.type),
|
||||
changeTimeText: formatTime(item.changeTime)
|
||||
}
|
||||
}),
|
||||
rechargePlans: (Array.isArray(plans) ? plans : []).map(item => ({
|
||||
...item,
|
||||
amountText: `充 ${money(item.rechargeAmount)} 送 ${money(item.giftAmount)}`
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || 'VIP 信息加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `openRechargePanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
openRechargePanel() {
|
||||
this.setData({ rechargePanelVisible: true })
|
||||
},
|
||||
|
||||
/**
|
||||
* `closeRechargePanel` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
closeRechargePanel() {
|
||||
this.setData({ rechargePanelVisible: false })
|
||||
},
|
||||
|
||||
/**
|
||||
* `noop` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
noop() {
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<navigation-bar title="VIP 中心" showBack="{{true}}" fallbackPath="/pages/profile/index" color="#2d2430" background="#fff7f8"></navigation-bar>
|
||||
<view class="vip-page">
|
||||
<view class="vip-hero">
|
||||
<text class="vip-kicker">会员等级</text>
|
||||
<text class="vip-level">{{asset.vipLevel || '普通'}}</text>
|
||||
<text class="vip-benefit">{{asset.benefitInfo || '暂无额外权益说明'}}</text>
|
||||
</view>
|
||||
|
||||
<view class="metric-grid">
|
||||
<view class="metric">
|
||||
<text>余额</text>
|
||||
<text class="metric-value">¥{{asset.balanceText}}</text>
|
||||
</view>
|
||||
<view class="metric">
|
||||
<text>累计充值</text>
|
||||
<text class="metric-value">¥{{asset.totalRechargeText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="recharge-entry" bindtap="openRechargePanel">去充值 / 查看充值说明</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">会员信息</view>
|
||||
<view class="info-row"><text>最近充值</text><text>{{asset.lastRechargeText}}</text></view>
|
||||
<view class="info-row"><text>生效时间</text><text>{{asset.vipStartText}}</text></view>
|
||||
<view class="info-row"><text>等级来源</text><text>{{asset.manualOverride ? '后台指定' : '自动计算'}}</text></view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">余额变动</view>
|
||||
<block wx:if="{{history.length}}">
|
||||
<view wx:for="{{history}}" wx:key="id" class="history-row">
|
||||
<view>
|
||||
<text class="history-title">{{item.sceneText}}</text>
|
||||
<text class="history-time">{{item.changeTimeText}}</text>
|
||||
<text wx:if="{{item.remark}}" class="history-remark">{{item.remark}}</text>
|
||||
</view>
|
||||
<text class="history-amount {{item.amountNumber > 0 ? 'income' : ''}}">{{item.amountText}}</text>
|
||||
</view>
|
||||
</block>
|
||||
<view wx:else class="empty">暂无余额变动</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{rechargePanelVisible}}" class="recharge-mask" bindtap="closeRechargePanel">
|
||||
<view class="recharge-panel" catchtap="noop">
|
||||
<view class="section-title">充值档位展示</view>
|
||||
<block wx:if="{{rechargePlans.length}}">
|
||||
<view wx:for="{{rechargePlans}}" wx:key="id" class="recharge-plan">
|
||||
<view class="plan-head">
|
||||
<text>{{item.title}}</text>
|
||||
<text>{{item.vipLevel}}</text>
|
||||
</view>
|
||||
<text class="plan-amount">{{item.amountText}}</text>
|
||||
<text class="plan-desc">{{item.description || '该档位仅展示,暂不发起支付。'}}</text>
|
||||
</view>
|
||||
</block>
|
||||
<view wx:else class="empty">暂无可展示充值档位</view>
|
||||
<view class="recharge-close" bindtap="closeRechargePanel">关闭</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,162 @@
|
||||
.vip-page {
|
||||
min-height: 100vh;
|
||||
padding: 24rpx;
|
||||
background: #f7f4f1;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.vip-hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
padding: 36rpx;
|
||||
border-radius: 16rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #2b2522, #8a704e);
|
||||
}
|
||||
|
||||
.vip-kicker, .vip-benefit {
|
||||
color: rgba(255,255,255,.76);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.vip-level {
|
||||
font-size: 56rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.metric, .section {
|
||||
padding: 28rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.metric {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
color: #7f7470;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
color: #2d2927;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin-bottom: 20rpx;
|
||||
color: #2d2927;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.info-row, .history-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid #f0ece8;
|
||||
}
|
||||
|
||||
.info-row:last-child, .history-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.history-title, .history-time, .history-remark {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.history-title {
|
||||
color: #2d2927;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.history-time, .history-remark, .empty {
|
||||
margin-top: 6rpx;
|
||||
color: #9a918d;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.history-amount {
|
||||
color: #2d2927;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.history-amount.income {
|
||||
color: #0f8f63;
|
||||
}
|
||||
|
||||
.recharge-entry {
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #fff7ed;
|
||||
color: #9a5b2e;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.recharge-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
z-index: 30;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.recharge-panel {
|
||||
width: 100%;
|
||||
max-height: 75vh;
|
||||
overflow: auto;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
background: #fff;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.recharge-plan {
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid #f0ece8;
|
||||
}
|
||||
|
||||
.plan-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 18rpx;
|
||||
color: #2d2927;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.plan-amount {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
color: #9a5b2e;
|
||||
}
|
||||
|
||||
.plan-desc {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
color: #9a918d;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.recharge-close {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #f4f0eb;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -6,6 +6,10 @@ const navigation = require('../../utils/navigation')
|
||||
const { buildProductCard } = require('../../utils/product')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* wishlist page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
@@ -13,6 +17,10 @@ Page({
|
||||
wishlist: []
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadWishlist()
|
||||
},
|
||||
@@ -24,6 +32,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.cartProductIdSet = new Set()
|
||||
this.setData({
|
||||
@@ -63,6 +75,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `normalizeId` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
},
|
||||
@@ -83,6 +99,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `markCardInCart` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
markCardInCart(card, idSet) {
|
||||
return {
|
||||
...card,
|
||||
@@ -90,8 +110,16 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `markWishlistProductInCart` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
markWishlistProductInCart(productId) {
|
||||
const normalizedId = this.normalizeId(productId)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!normalizedId) {
|
||||
return
|
||||
}
|
||||
@@ -114,12 +142,24 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/wishlist/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProductSelect` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProductSelect(event) {
|
||||
const product = event.detail || {}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product.id) {
|
||||
return
|
||||
}
|
||||
@@ -132,6 +172,10 @@ Page({
|
||||
async handleQuickAdd(event) {
|
||||
const product = event.detail || {}
|
||||
const productId = this.normalizeId(product.id)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
@@ -174,6 +218,10 @@ Page({
|
||||
|
||||
async handleRemove(event) {
|
||||
const productId = event.currentTarget.dataset.productId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
@@ -198,6 +246,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ async function buildProductCard(product) {
|
||||
...product,
|
||||
displayTitle: getProductTitle(product),
|
||||
priceText: `¥${formatPrice(product && product.price)}`,
|
||||
metaText: (product && (product.approximateDuration || product.shopName)) || '支持预约',
|
||||
metaText: (product && product.approximateDuration) || '支持预约',
|
||||
shopNameText: product && product.shopName ? `所属店铺:${product.shopName}` : '',
|
||||
coverUrl: images[0],
|
||||
imageUrls: images,
|
||||
tagsPreview: getProductTags(product),
|
||||
|
||||
@@ -36,6 +36,7 @@ function isWhitelistedPath(url) {
|
||||
'/user/phone-login',
|
||||
'/user/wechat-mini/',
|
||||
'/user/reset-password-by-phone',
|
||||
'/legal-agreement/current',
|
||||
'/product/get/',
|
||||
'/product/list/',
|
||||
'/comment/list/product/',
|
||||
|
||||
@@ -91,11 +91,22 @@ public class AuthInterceptor implements HandlerInterceptor {
|
||||
if (!canAccessShop) {
|
||||
String message = currentShopId == null || currentShopId <= 0
|
||||
? "当前登录未选择可用店铺,请重新登录"
|
||||
: "当前登录店铺已停用或账号已失去该店铺访问权限";
|
||||
: (userShopBindingSupport.isShopEnabledIgnoringAuthorization(currentShopId)
|
||||
&& userShopBindingSupport.isShopAuthorizationExpired(currentShopId)
|
||||
? "店铺已被冻结"
|
||||
: "当前登录店铺已停用或账号已失去该店铺访问权限");
|
||||
writeJsonResponse(response, HttpServletResponse.SC_UNAUTHORIZED, message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (adminPath
|
||||
&& !Integer.valueOf(4).equals(currentUser.getType())
|
||||
&& userShopBindingSupport.isShopAuthorizationExpired(currentShopId)
|
||||
&& !isExpiredAdminAllowedPath(path)) {
|
||||
writeJsonResponse(response, HttpServletResponse.SC_FORBIDDEN, "授权已到期,请联系管理员");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (requiresSignature(request)) {
|
||||
try {
|
||||
requestSignatureService.validateRequest(request, token, userId);
|
||||
@@ -142,6 +153,14 @@ public class AuthInterceptor implements HandlerInterceptor {
|
||||
return path.startsWith("/admin/") || path.startsWith("/order/admin/");
|
||||
}
|
||||
|
||||
private boolean isExpiredAdminAllowedPath(String path) {
|
||||
return path.startsWith("/admin/auth/")
|
||||
|| path.equals("/admin/user/info")
|
||||
|| path.equals("/permission/list/user/current")
|
||||
|| path.equals("/api/permission/list/user/current")
|
||||
|| path.startsWith("/admin/shops/");
|
||||
}
|
||||
|
||||
private void writeJsonResponse(HttpServletResponse response, int status, String message) throws Exception {
|
||||
response.setStatus(status);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiaowang.yuminailcore.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "yuminail.security.login-lock")
|
||||
public class LoginLockProperties {
|
||||
|
||||
private int maxFailures = 5;
|
||||
|
||||
private long windowSeconds = 600;
|
||||
|
||||
private long lockSeconds = 900;
|
||||
}
|
||||
@@ -14,10 +14,16 @@ public class RateLimitProperties {
|
||||
|
||||
private LimitRule login = new LimitRule(10, 60);
|
||||
|
||||
private LimitRule register = new LimitRule(5, 300);
|
||||
|
||||
private LimitRule sendCode = new LimitRule(5, 60);
|
||||
|
||||
private LimitRule resetPassword = new LimitRule(5, 600);
|
||||
|
||||
private LimitRule wechatMiniLogin = new LimitRule(10, 60);
|
||||
|
||||
private LimitRule agreementRead = new LimitRule(60, 60);
|
||||
|
||||
private LimitRule authenticatedWrite = new LimitRule(80, 60);
|
||||
|
||||
private LimitRule orderCreate = new LimitRule(10, 60);
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.xiaowang.yuminailcore.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class SecurityHeadersFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
if (response instanceof HttpServletResponse httpResponse) {
|
||||
httpResponse.setHeader("X-Content-Type-Options", "nosniff");
|
||||
httpResponse.setHeader("X-Frame-Options", "DENY");
|
||||
httpResponse.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
|
||||
httpResponse.setHeader("Content-Security-Policy", "default-src 'self'; img-src 'self' data: blob: http: https:; style-src 'self' 'unsafe-inline'; script-src 'self'; connect-src 'self' http: https:");
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.xiaowang.yuminailcore.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "yuminail.security.upload")
|
||||
public class UploadSecurityProperties {
|
||||
|
||||
private long maxSize = 10 * 1024 * 1024;
|
||||
|
||||
private List<String> allowedMimeTypes = new ArrayList<>(List.of(
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/webp",
|
||||
"image/gif"
|
||||
));
|
||||
}
|
||||
@@ -30,6 +30,10 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
"/user/phone-login",
|
||||
"/user/wechat-mini/**",
|
||||
"/user/reset-password-by-phone",
|
||||
"/legal-agreement/current",
|
||||
"/legal-agreement/current/**",
|
||||
"/api/legal-agreement/current",
|
||||
"/api/legal-agreement/current/**",
|
||||
"/product/get/**",
|
||||
"/product/list/**",
|
||||
"/comment/list/product/**",
|
||||
|
||||
+59
-3
@@ -6,6 +6,7 @@ import com.xiaowang.yuminailcore.dto.LoginRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.RefreshTokenRequestDTO;
|
||||
import com.xiaowang.yuminailcore.dto.SwitchShopRequestDTO;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.service.SecurityAuditLogService;
|
||||
import com.xiaowang.yuminailcore.support.security.RequestThrottleService;
|
||||
import com.xiaowang.yuminailcore.support.security.OperationGuardStrategy;
|
||||
import com.xiaowang.yuminailcore.utils.AccountValidationUtils;
|
||||
@@ -20,26 +21,64 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@RestController
|
||||
@RequestMapping("/admin/auth")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminAuthController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminAuthController {
|
||||
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `requestThrottleService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final RequestThrottleService requestThrottleService;
|
||||
private final SecurityAuditLogService securityAuditLogService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@OperationGuard(action = "admin-login", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
/**
|
||||
* Run the login flow.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param loginRequestDTO parameter `loginRequestDTO` supplied by the caller
|
||||
* @return Result<LoginResponseVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginResponseVO> login(HttpServletRequest request, @Valid @RequestBody LoginRequestDTO loginRequestDTO) {
|
||||
requestThrottleService.checkLogin(request, loginRequestDTO.getAccount());
|
||||
LoginResponseVO loginResponseVO = userService.adminLogin(loginRequestDTO);
|
||||
return Result.success(loginResponseVO);
|
||||
try {
|
||||
LoginResponseVO loginResponseVO = userService.adminLogin(loginRequestDTO);
|
||||
requestThrottleService.clearLoginFailure(request, loginRequestDTO.getAccount());
|
||||
securityAuditLogService.record(loginResponseVO.getUserInfo().getId(), loginRequestDTO.getAccount(), "ADMIN_LOGIN", "SUCCESS", null, request);
|
||||
return Result.success(loginResponseVO);
|
||||
} catch (RuntimeException exception) {
|
||||
requestThrottleService.recordLoginFailure(request, loginRequestDTO.getAccount());
|
||||
securityAuditLogService.record(null, loginRequestDTO.getAccount(), "ADMIN_LOGIN", "FAIL", exception.getMessage(), request);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/login-shops/{account}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param account parameter `account` supplied by the caller
|
||||
* @return Result<LoginShopSelectionVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginShopSelectionVO> getLoginShops(@PathVariable String account) {
|
||||
return Result.success(userService.getAdminLoginShopSelection(AccountValidationUtils.requireValidAccount(account)));
|
||||
}
|
||||
|
||||
@PostMapping("/switch-shop")
|
||||
@OperationGuard(action = "admin-switch-shop", ttlSeconds = 10, message = "门店切换中,请勿重复操作")
|
||||
/**
|
||||
* Run business method `switchShop`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param switchShopRequestDTO parameter `switchShopRequestDTO` supplied by the caller
|
||||
* @return Result<LoginResponseVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginResponseVO> switchShop(HttpServletRequest request, @RequestBody SwitchShopRequestDTO switchShopRequestDTO) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(userService.switchAdminShop(userId, switchShopRequestDTO.getShopId(), (String) request.getAttribute("sessionId")));
|
||||
@@ -47,16 +86,33 @@ public class AdminAuthController {
|
||||
|
||||
@PostMapping("/logout")
|
||||
@OperationGuard(action = "admin-logout", strategy = OperationGuardStrategy.NOOP_IF_DUPLICATE, ttlSeconds = 5)
|
||||
/**
|
||||
* Run business method `logout`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> logout(HttpServletRequest request) {
|
||||
return Result.success(userService.logout((String) request.getAttribute("sessionId")));
|
||||
}
|
||||
|
||||
@PostMapping("/refresh")
|
||||
/**
|
||||
* Run business method `refreshToken`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param refreshTokenRequestDTO parameter `refreshTokenRequestDTO` supplied by the caller
|
||||
* @return Result<LoginResponseVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginResponseVO> refreshToken(@RequestBody RefreshTokenRequestDTO refreshTokenRequestDTO) {
|
||||
LoginResponseVO loginResponseVO = userService.refreshToken(refreshTokenRequestDTO.getRefreshToken());
|
||||
if (loginResponseVO.getUserInfo() == null
|
||||
|| loginResponseVO.getUserInfo().getType() == null
|
||||
|| loginResponseVO.getUserInfo().getType() < 2) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("您没有后台管理权限");
|
||||
}
|
||||
return Result.success(loginResponseVO);
|
||||
|
||||
+17
-1
@@ -20,9 +20,18 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/admin/comment")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminCommentController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminCommentController {
|
||||
|
||||
/**
|
||||
* Variable `commentService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final CommentService commentService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/list")
|
||||
@@ -41,6 +50,13 @@ public class AdminCommentController {
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("comment:delete")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteComment(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long managedShopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
|
||||
+9
-1
@@ -25,9 +25,17 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/admin/coupon")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminCouponController {
|
||||
|
||||
/**
|
||||
* Variable `couponService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final CouponService couponService;
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
/**
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.LegalAgreementDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.LegalAgreementService;
|
||||
import com.xiaowang.yuminailcore.service.SecurityAuditLogService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.LegalAgreementVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/admin/legal-agreement")
|
||||
public class AdminLegalAgreementController {
|
||||
|
||||
private final LegalAgreementService legalAgreementService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditLogService securityAuditLogService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
public Result<List<LegalAgreementVO>> list(HttpServletRequest request) {
|
||||
return Result.success(legalAgreementService.listAdminAgreements(adminScopeHelper.getCurrentUser(request)));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "admin-legal-agreement-create", ttlSeconds = 8, message = "协议保存处理中,请勿重复提交")
|
||||
public Result<Long> create(HttpServletRequest request, @Valid @RequestBody LegalAgreementDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long id = legalAgreementService.createAgreement(currentUser, dto);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_CREATE", "SUCCESS", dto.getAgreementType(), request);
|
||||
return Result.success(id);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "admin-legal-agreement-update", ttlSeconds = 8, message = "协议保存处理中,请勿重复提交")
|
||||
public Result<Boolean> update(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody LegalAgreementDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Boolean result = legalAgreementService.updateAgreement(currentUser, id, dto);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_UPDATE", "SUCCESS", String.valueOf(id), request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/publish")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "admin-legal-agreement-publish", ttlSeconds = 8, message = "协议发布处理中,请勿重复提交")
|
||||
public Result<Boolean> publish(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Boolean result = legalAgreementService.publishAgreement(currentUser, id);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_PUBLISH", "SUCCESS", String.valueOf(id), request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/disable")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "admin-legal-agreement-disable", ttlSeconds = 8, message = "协议停用处理中,请勿重复提交")
|
||||
public Result<Boolean> disable(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Boolean result = legalAgreementService.disableAgreement(currentUser, id);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_DISABLE", "SUCCESS", String.valueOf(id), request);
|
||||
return Result.success(result);
|
||||
}
|
||||
}
|
||||
+30
-1
@@ -21,17 +21,32 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/admin/nail-artist")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminNailArtistController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminNailArtistController {
|
||||
|
||||
private static final String USER_NOT_FOUND_MESSAGE = "用户信息不存在";
|
||||
private static final String VIEW_SCOPE_MESSAGE = "当前登录店铺无权查看该美甲师,请切换到所属店铺后重试";
|
||||
private static final String EDIT_SCOPE_MESSAGE = "当前登录店铺无权编辑该美甲师,请切换到所属店铺后重试";
|
||||
|
||||
/**
|
||||
* Variable `nailArtistInfoService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final NailArtistInfoService nailArtistInfoService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@RequirePermission("nail_artist:view")
|
||||
@GetMapping("/list")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<NailArtistInfoDTO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<NailArtistInfoDTO>> getAllNailArtists(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (currentUser == null) {
|
||||
@@ -52,6 +67,13 @@ public class AdminNailArtistController {
|
||||
|
||||
@RequirePermission("nail_artist:view")
|
||||
@GetMapping("/get/{userId}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<NailArtistInfoDTO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<NailArtistInfoDTO> getNailArtistInfo(@PathVariable Long userId, HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (currentUser == null) {
|
||||
@@ -77,6 +99,13 @@ public class AdminNailArtistController {
|
||||
@RequirePermission("nail_artist:edit")
|
||||
@PostMapping("/save")
|
||||
@OperationGuard(action = "admin-nail-artist-save", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Save submitted data.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param nailArtistInfoDTO parameter `nailArtistInfoDTO` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<NailArtistInfoDTO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<NailArtistInfoDTO> saveNailArtistInfo(@RequestBody NailArtistInfoDTO nailArtistInfoDTO, HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (currentUser == null) {
|
||||
|
||||
+11
-1
@@ -21,8 +21,13 @@ import java.util.List;
|
||||
@RequestMapping("/admin/order")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminOrderController {
|
||||
|
||||
/**
|
||||
* Variable `orderService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final OrderService orderService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
/**
|
||||
@@ -87,6 +92,11 @@ public class AdminOrderController {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (Integer.valueOf(3).equals(currentUser.getType())) {
|
||||
if (!Integer.valueOf(2).equals(status)) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("美甲师只能完成属于自己的订单");
|
||||
}
|
||||
orderService.completeArtistOrder(id, currentUser.getId());
|
||||
|
||||
+77
-1
@@ -19,15 +19,34 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/admin/permission")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminPermissionController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminPermissionController {
|
||||
|
||||
/**
|
||||
* Variable `permissionService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final PermissionService permissionService;
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("permission:create")
|
||||
@OperationGuard(action = "admin-permission-create", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param permissionDTO parameter `permissionDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createPermission(HttpServletRequest request, @RequestBody PermissionDTO permissionDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以维护权限定义");
|
||||
@@ -38,6 +57,14 @@ public class AdminPermissionController {
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission("permission:edit")
|
||||
@OperationGuard(action = "admin-permission-update", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param permissionDTO parameter `permissionDTO` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updatePermission(HttpServletRequest request, @PathVariable Long id, @RequestBody PermissionDTO permissionDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以维护权限定义");
|
||||
@@ -48,6 +75,13 @@ public class AdminPermissionController {
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("permission:delete")
|
||||
@OperationGuard(action = "admin-permission-delete", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deletePermission(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以维护权限定义");
|
||||
@@ -57,6 +91,12 @@ public class AdminPermissionController {
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
@RequirePermission("permission:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<PermissionVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<PermissionVO> getPermissionById(@PathVariable Long id) {
|
||||
PermissionVO permissionVO = permissionService.getPermissionById(id);
|
||||
return Result.success(permissionVO);
|
||||
@@ -64,6 +104,11 @@ public class AdminPermissionController {
|
||||
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("permission:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<List<PermissionVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<PermissionVO>> listAllPermissions() {
|
||||
List<PermissionVO> permissionVOs = permissionService.listAllPermissions();
|
||||
return Result.success(permissionVOs);
|
||||
@@ -71,6 +116,12 @@ public class AdminPermissionController {
|
||||
|
||||
@GetMapping("/list/group/{permissionGroup}")
|
||||
@RequirePermission("permission:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param permissionGroup parameter `permissionGroup` supplied by the caller
|
||||
* @return Result<List<PermissionVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<PermissionVO>> listPermissionsByGroup(@PathVariable String permissionGroup) {
|
||||
List<PermissionVO> permissionVOs = permissionService.listPermissionsByGroup(permissionGroup);
|
||||
return Result.success(permissionVOs);
|
||||
@@ -78,11 +129,23 @@ public class AdminPermissionController {
|
||||
|
||||
@GetMapping("/user/{userId}")
|
||||
@RequirePermission("permission:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @return Result<List<PermissionVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<PermissionVO>> listUserPermissions(HttpServletRequest request, @PathVariable Long userId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
UserDO targetUser = userService.getById(userId);
|
||||
if (targetUser == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("目标用户不存在");
|
||||
}
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, "无权查看其他店铺用户权限");
|
||||
@@ -93,6 +156,13 @@ public class AdminPermissionController {
|
||||
|
||||
@GetMapping("/assignable/{userId}")
|
||||
@RequirePermission("permission:assign")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @return Result<List<Long>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<Long>> listAssignablePermissionIds(HttpServletRequest request, @PathVariable Long userId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
@@ -103,6 +173,12 @@ public class AdminPermissionController {
|
||||
}
|
||||
|
||||
@GetMapping("/user/current")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<PermissionVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<PermissionVO>> getCurrentUserPermissions(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
userService.syncManagedPermissions(userId);
|
||||
|
||||
+38
-1
@@ -18,9 +18,18 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/admin/product")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminProductController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminProductController {
|
||||
|
||||
/**
|
||||
* Variable `productService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ProductService productService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/list")
|
||||
@@ -41,6 +50,13 @@ public class AdminProductController {
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("product:create")
|
||||
@OperationGuard(action = "admin-product-create", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param productDTO parameter `productDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createProduct(HttpServletRequest request, @RequestBody ProductDTO productDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
productDTO.setShopId(adminScopeHelper.resolveShopScope(currentUser, productDTO.getShopId()));
|
||||
@@ -51,6 +67,14 @@ public class AdminProductController {
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission("product:edit")
|
||||
@OperationGuard(action = "admin-product-update", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param productDTO parameter `productDTO` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateProduct(HttpServletRequest request, @PathVariable Long id, @RequestBody ProductDTO productDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
ProductVO productVO = productService.getProductById(id);
|
||||
@@ -67,6 +91,13 @@ public class AdminProductController {
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("product:delete")
|
||||
@OperationGuard(action = "admin-product-delete", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteProduct(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
ProductVO productVO = productService.getProductById(id);
|
||||
@@ -80,6 +111,12 @@ public class AdminProductController {
|
||||
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("product:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<ProductVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ProductVO>> listAllProducts(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
|
||||
+56
-1
@@ -19,9 +19,18 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/admin/shops")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminShopController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminShopController {
|
||||
|
||||
/**
|
||||
* Variable `shopService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopService shopService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/list")
|
||||
@@ -42,6 +51,13 @@ public class AdminShopController {
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("shop:create")
|
||||
@OperationGuard(action = "admin-shop-create", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param shopDTO parameter `shopDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createShop(HttpServletRequest request, @RequestBody ShopDTO shopDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以创建店铺");
|
||||
@@ -52,6 +68,14 @@ public class AdminShopController {
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission("shop:edit")
|
||||
@OperationGuard(action = "admin-shop-update", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param shopDTO parameter `shopDTO` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateShop(HttpServletRequest request, @PathVariable Long id, @RequestBody ShopDTO shopDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
ShopVO shopVO = shopService.getShopById(id);
|
||||
@@ -59,6 +83,9 @@ public class AdminShopController {
|
||||
return Result.success(false);
|
||||
}
|
||||
adminScopeHelper.ensureShopAccessible(currentUser, shopVO.getId(), "无权编辑其他店铺信息");
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
shopDTO.setAuthorizationExpireTime(shopVO.getAuthorizationExpireTime());
|
||||
}
|
||||
boolean success = shopService.updateShop(id, shopDTO);
|
||||
return Result.success(success);
|
||||
}
|
||||
@@ -66,6 +93,13 @@ public class AdminShopController {
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("shop:delete")
|
||||
@OperationGuard(action = "admin-shop-delete", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteShop(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以删除店铺");
|
||||
@@ -76,6 +110,14 @@ public class AdminShopController {
|
||||
@PutMapping("/status/{id}")
|
||||
@RequirePermission("shop:edit")
|
||||
@OperationGuard(action = "admin-shop-status", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param statusRequest parameter `statusRequest` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateShopStatus(HttpServletRequest request, @PathVariable Long id, @RequestBody StatusRequest statusRequest) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以启停店铺");
|
||||
@@ -85,6 +127,12 @@ public class AdminShopController {
|
||||
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("shop:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<ShopVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ShopVO>> listAllShops(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
List<ShopVO> shops;
|
||||
@@ -99,6 +147,13 @@ public class AdminShopController {
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@RequirePermission("shop:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<ShopVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ShopVO> getShop(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.ensureShopAccessible(currentUser, id, "无权查看其他店铺信息");
|
||||
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.InviteCodeDTO;
|
||||
import com.xiaowang.yuminailcore.dto.ShopRoleDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.PermissionService;
|
||||
import com.xiaowang.yuminailcore.service.ShopRoleService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.InviteCodeVO;
|
||||
import com.xiaowang.yuminailcore.vo.PermissionVO;
|
||||
import com.xiaowang.yuminailcore.vo.ShopRoleVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/shop-role")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminShopRoleController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminShopRoleController {
|
||||
/**
|
||||
* Variable `shopRoleService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopRoleService shopRoleService;
|
||||
/**
|
||||
* Variable `permissionService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final PermissionService permissionService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("role:view")
|
||||
// 店铺角色是“只在本店生效”的角色,不是全局后台角色;
|
||||
// 所以这里要先按当前登录人的店铺范围裁剪,再返回列表。
|
||||
public Result<List<ShopRoleVO>> list(HttpServletRequest request, @RequestParam(required = false) Long shopId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.listRoles(currentUser, shopId));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("role:create")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> create(HttpServletRequest request, @Valid @RequestBody ShopRoleDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.createRole(currentUser, dto));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@RequirePermission("role:edit")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> update(HttpServletRequest request, @PathVariable Long id, @RequestBody ShopRoleDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.updateRole(currentUser, id, dto));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@RequirePermission("role:delete")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> delete(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.deleteRole(currentUser, id));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/permissions")
|
||||
@RequirePermission("role:edit")
|
||||
/**
|
||||
* Run business method `assignPermissions`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param permissionIds parameter `permissionIds` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> assignPermissions(HttpServletRequest request, @PathVariable Long id, @RequestBody List<Long> permissionIds) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.assignPermissions(currentUser, id, permissionIds));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/users")
|
||||
@RequirePermission("role:edit")
|
||||
/**
|
||||
* Run business method `assignUsers`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param userIds parameter `userIds` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> assignUsers(HttpServletRequest request, @PathVariable Long id, @RequestBody List<Long> userIds) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.assignUsers(currentUser, id, userIds));
|
||||
}
|
||||
|
||||
@GetMapping("/permission-options")
|
||||
@RequirePermission("role:view")
|
||||
/**
|
||||
* Run business method `permissionOptions`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<List<PermissionVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<PermissionVO>> permissionOptions() {
|
||||
return Result.success(permissionService.listAllPermissions());
|
||||
}
|
||||
|
||||
@GetMapping("/invite-code/list")
|
||||
@RequirePermission("user:relation:view")
|
||||
public Result<List<InviteCodeVO>> listInviteCodes(HttpServletRequest request, @RequestParam(required = false) Long shopId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.listInviteCodes(currentUser, shopId));
|
||||
}
|
||||
|
||||
@PostMapping("/invite-code/create")
|
||||
@RequirePermission("user:relation:edit")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createInviteCode(HttpServletRequest request, @Valid @RequestBody InviteCodeDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.createInviteCode(currentUser, dto));
|
||||
}
|
||||
|
||||
@PutMapping("/invite-code/{id}/status")
|
||||
@RequirePermission("user:relation:edit")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param status parameter `status` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateInviteCodeStatus(HttpServletRequest request, @PathVariable Long id, @RequestParam Integer status) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.updateInviteCodeStatus(currentUser, id, status));
|
||||
}
|
||||
|
||||
@GetMapping("/invite-code/resolve")
|
||||
// 注册页输入邀请码时调用这个接口,用来提前展示“会归属到谁、哪个店”。
|
||||
/**
|
||||
* Run business method `resolve`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param code parameter `code` supplied by the caller
|
||||
* @return Result<InviteCodeVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<InviteCodeVO> resolve(@RequestParam String code) {
|
||||
return Result.success(shopRoleService.resolveInviteCode(code));
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -21,8 +21,13 @@ import java.util.List;
|
||||
@RequestMapping("/admin/tag")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminTagController {
|
||||
|
||||
/**
|
||||
* Variable `tagService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final TagService tagService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
/**
|
||||
|
||||
+195
-4
@@ -6,13 +6,18 @@ import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.AdminUserBalanceChangeDTO;
|
||||
import com.xiaowang.yuminailcore.dto.AdminUserVipOverrideDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UserDTO;
|
||||
import com.xiaowang.yuminailcore.dto.UserRelationUpdateDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.UserAssetService;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.service.ShopRoleService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.BookableArtistSupport;
|
||||
import com.xiaowang.yuminailcore.vo.BalanceChangeDetailVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserStatisticsVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserAssetVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserRelationVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserVO;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -26,11 +31,31 @@ import java.util.stream.Collectors;
|
||||
@RestController
|
||||
@RequestMapping("/admin/user")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* AdminUserController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AdminUserController {
|
||||
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `userAssetService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserAssetService userAssetService;
|
||||
/**
|
||||
* Variable `shopRoleService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopRoleService shopRoleService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
/**
|
||||
* Variable `bookableArtistSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final BookableArtistSupport bookableArtistSupport;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("user:view")
|
||||
@@ -40,17 +65,87 @@ public class AdminUserController {
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Long shopId,
|
||||
@RequestParam(required = false) Integer type
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Long roleId,
|
||||
@RequestParam(required = false) Long parentUserId,
|
||||
@RequestParam(required = false) String sourceType,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String vipLevel,
|
||||
@RequestParam(required = false) String createdFrom,
|
||||
@RequestParam(required = false) String createdTo,
|
||||
@RequestParam(required = false) Boolean hasPhone,
|
||||
@RequestParam(required = false) Boolean hasOrder
|
||||
) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
shopId = adminScopeHelper.resolveShopScope(currentUser, shopId);
|
||||
PageResultVO<UserVO> result = userService.pageUsers(page, size, keyword, shopId, type);
|
||||
PageResultVO<UserVO> result = userService.pageUsers(page, size, keyword, shopId, type, roleId, parentUserId, sourceType, status, vipLevel, createdFrom, createdTo, hasPhone, hasOrder);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@RequirePermission("user:view")
|
||||
public Result<UserStatisticsVO> statisticsUsers(HttpServletRequest request,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Long shopId,
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Long roleId,
|
||||
@RequestParam(required = false) Long parentUserId,
|
||||
@RequestParam(required = false) String sourceType,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String vipLevel,
|
||||
@RequestParam(required = false) String createdFrom,
|
||||
@RequestParam(required = false) String createdTo,
|
||||
@RequestParam(required = false) Boolean hasPhone,
|
||||
@RequestParam(required = false) Boolean hasOrder) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
shopId = adminScopeHelper.resolveShopScope(currentUser, shopId);
|
||||
return Result.success(userService.statisticsUsers(keyword, shopId, type, roleId, parentUserId, sourceType, status, vipLevel, createdFrom, createdTo, hasPhone, hasOrder));
|
||||
}
|
||||
|
||||
@GetMapping("/relation/me")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<UserRelationVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<UserRelationVO> getMyRelation(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(userService.getCurrentUserRelation(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/relation/options")
|
||||
@RequirePermission("user:relation:view")
|
||||
public Result<List<UserRelationVO>> relationOptions(HttpServletRequest request, @RequestParam(required = false) Long shopId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.listRelationOptions(currentUser, shopId));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/relation")
|
||||
@RequirePermission("user:relation:edit")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateRelation(HttpServletRequest request, @PathVariable Long id, @RequestBody UserRelationUpdateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(shopRoleService.updateUserRelation(currentUser, id, dto));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("user:create")
|
||||
@OperationGuard(action = "admin-user-create", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param userDTO parameter `userDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createUser(HttpServletRequest request, @Valid @RequestBody UserDTO userDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.ensureAssignableUserType(currentUser, userDTO.getType());
|
||||
@@ -66,6 +161,14 @@ public class AdminUserController {
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission("user:edit")
|
||||
@OperationGuard(action = "admin-user-update", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param userDTO parameter `userDTO` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateUser(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody UserDTO userDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = userService.getUserById(id);
|
||||
@@ -87,6 +190,14 @@ public class AdminUserController {
|
||||
@PutMapping("/status/{id}")
|
||||
@RequirePermission("user:disable")
|
||||
@OperationGuard(action = "admin-user-status", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param httpRequest parameter `httpRequest` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateUserStatus(HttpServletRequest httpRequest, @PathVariable Long id, @RequestBody StatusRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(httpRequest);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "仅系统管理员可以停用用户");
|
||||
@@ -96,6 +207,11 @@ public class AdminUserController {
|
||||
}
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, id, "无权变更其他店铺用户状态");
|
||||
if (Integer.valueOf(4).equals(targetUser.getType())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("管理员账号不允许停用");
|
||||
}
|
||||
boolean success = userService.updateUserStatus(id, request.getStatus());
|
||||
@@ -105,6 +221,13 @@ public class AdminUserController {
|
||||
@PostMapping("/reset-password/{userId}")
|
||||
@RequirePermission("user:reset_password")
|
||||
@OperationGuard(action = "admin-user-reset-password", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Run business method `resetPassword`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> resetPassword(HttpServletRequest request, @PathVariable Long userId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = userService.getUserById(userId);
|
||||
@@ -120,6 +243,13 @@ public class AdminUserController {
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("user:delete")
|
||||
@OperationGuard(action = "admin-user-delete", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteUser(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "仅系统管理员可以删除用户");
|
||||
@@ -128,6 +258,11 @@ public class AdminUserController {
|
||||
return Result.success(false);
|
||||
}
|
||||
if (Integer.valueOf(4).equals(targetUser.getType())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("管理员账号不允许删除");
|
||||
}
|
||||
boolean success = userService.deleteUser(id);
|
||||
@@ -137,6 +272,13 @@ public class AdminUserController {
|
||||
@PutMapping("/unbind/{id}")
|
||||
@RequirePermission("user:unbind")
|
||||
@OperationGuard(action = "admin-user-unbind", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Run business method `unbindUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> unbindUser(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = userService.getUserById(id);
|
||||
@@ -146,6 +288,11 @@ public class AdminUserController {
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, id, "无权解绑其他店铺用户");
|
||||
adminScopeHelper.ensureAssignableUserType(currentUser, targetUser.getType());
|
||||
if (Integer.valueOf(4).equals(targetUser.getType())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("管理员账号不允许解绑");
|
||||
}
|
||||
boolean success = userService.unbindUserInShopWithOperator(id, currentUser.getShopId(), currentUser.getType());
|
||||
@@ -154,6 +301,13 @@ public class AdminUserController {
|
||||
|
||||
@GetMapping("/{id}/asset")
|
||||
@RequirePermission("user:balance:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<UserAssetVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<UserAssetVO> getUserAsset(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = requireAccessibleUser(currentUser, id, "无权查看其他店铺用户资产");
|
||||
@@ -163,6 +317,13 @@ public class AdminUserController {
|
||||
|
||||
@GetMapping("/{id}/balance/history")
|
||||
@RequirePermission("user:balance:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<List<BalanceChangeDetailVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<BalanceChangeDetailVO>> getUserBalanceHistory(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = requireAccessibleUser(currentUser, id, "无权查看其他店铺用户余额流水");
|
||||
@@ -201,6 +362,13 @@ public class AdminUserController {
|
||||
@PostMapping("/{id}/vip/recalculate")
|
||||
@RequirePermission("user:vip:manage")
|
||||
@OperationGuard(action = "admin-user-vip-recalculate", ttlSeconds = 15, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Run business method `recalculateUserVip`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<UserAssetVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<UserAssetVO> recalculateUserVip(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = requireAccessibleUser(currentUser, id, "无权重算其他店铺用户 VIP");
|
||||
@@ -209,6 +377,12 @@ public class AdminUserController {
|
||||
}
|
||||
|
||||
@GetMapping("/info")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<UserVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<UserVO> getUserInfo(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
UserVO userVO = userService.getUserById(userId);
|
||||
@@ -239,8 +413,12 @@ public class AdminUserController {
|
||||
public Result<List<UserVO>> listArtists(HttpServletRequest request, @RequestParam(required = false) Long shopId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
shopId = adminScopeHelper.resolveShopScope(currentUser, shopId);
|
||||
final Long resolvedScopeShopId = shopId;
|
||||
List<UserVO> artists = userService.listAllUsers().stream()
|
||||
.filter(user -> Integer.valueOf(2).equals(user.getType()) || Integer.valueOf(3).equals(user.getType()))
|
||||
.filter(user -> bookableArtistSupport.isValidBookableArtist(resolvedScopeShopId, user.getId()))
|
||||
.collect(Collectors.toList());
|
||||
// 用户类型 3 表示美甲师
|
||||
List<UserVO> artists = userService.listUsersByType(3);
|
||||
// 如果指定了店铺ID,则过滤该店铺的美甲师
|
||||
if (shopId != null) {
|
||||
final Long resolvedShopId = shopId;
|
||||
@@ -251,9 +429,22 @@ public class AdminUserController {
|
||||
return Result.success(artists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `requireAccessibleUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param currentUser parameter `currentUser` supplied by the caller
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @param message parameter `message` supplied by the caller
|
||||
* @return private UserVO result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private UserVO requireAccessibleUser(UserDO currentUser, Long userId, String message) {
|
||||
UserVO targetUser = userService.getUserById(userId);
|
||||
if (targetUser == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("目标用户不存在");
|
||||
}
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, message);
|
||||
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.AnnouncementCreateDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.AnnouncementService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.AnnouncementVO;
|
||||
import com.xiaowang.yuminailcore.vo.MessageTargetOptionsVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/announcement", "/api/announcement"})
|
||||
/**
|
||||
* AnnouncementController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class AnnouncementController {
|
||||
/**
|
||||
* Variable `announcementService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AnnouncementService announcementService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@PostMapping("/admin/create")
|
||||
@RequirePermission("announcement:create")
|
||||
@OperationGuard(action = "announcement-create", ttlSeconds = 8, message = "公告发布处理中,请勿重复提交")
|
||||
// 后台发布公告时,targetType 决定“全平台 / 指定店铺 / 指定用户”的范围。
|
||||
// 前端只需要按 target-options 返回值组装表单即可。
|
||||
/**
|
||||
* Run business method `publish`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> publish(HttpServletRequest request, @Valid @RequestBody AnnouncementCreateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(announcementService.publishAnnouncement(currentUser, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/list")
|
||||
@RequirePermission("announcement:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<AnnouncementVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<AnnouncementVO>> listAdmin(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(announcementService.listAdminAnnouncements(currentUser));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/{id}")
|
||||
@RequirePermission("announcement:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<AnnouncementVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<AnnouncementVO> getAdmin(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(announcementService.getAdminAnnouncement(currentUser, id));
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}/revoke")
|
||||
@RequirePermission("announcement:delete")
|
||||
@OperationGuard(action = "announcement-revoke", ttlSeconds = 8, message = "公告撤回处理中,请勿重复操作")
|
||||
/**
|
||||
* Run business method `revoke`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> revoke(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(announcementService.revokeAnnouncement(currentUser, id));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/target-options")
|
||||
@RequirePermission("announcement:create")
|
||||
/**
|
||||
* Run business method `targetOptions`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<MessageTargetOptionsVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<MessageTargetOptionsVO> targetOptions(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(announcementService.listTargetOptions(currentUser));
|
||||
}
|
||||
|
||||
@GetMapping("/my/list")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<AnnouncementVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<AnnouncementVO>> listMy(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(announcementService.listMyAnnouncements(userId));
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -20,7 +20,9 @@ import java.util.List;
|
||||
@RequestMapping({"/balance-change-detail", "/api/balance-change-detail"})
|
||||
@RequiredArgsConstructor
|
||||
public class BalanceChangeDetailController {
|
||||
|
||||
/**
|
||||
* Variable `balanceChangeDetailService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final BalanceChangeDetailService balanceChangeDetailService;
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ import java.util.List;
|
||||
@RequestMapping({"/balance", "/api/balance"})
|
||||
@RequiredArgsConstructor
|
||||
public class BalanceController {
|
||||
|
||||
/**
|
||||
* Variable `balanceService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final BalanceService balanceService;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,10 @@ import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cart")
|
||||
/**
|
||||
* CartController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class CartController {
|
||||
|
||||
@Resource
|
||||
@@ -21,6 +25,13 @@ public class CartController {
|
||||
|
||||
@PostMapping("/add")
|
||||
@OperationGuard(action = "cart-add", ttlSeconds = 10, message = "购物车处理中,请勿重复操作")
|
||||
/**
|
||||
* Add a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param cartDTO parameter `cartDTO` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> addToCart(@RequestBody CartDTO cartDTO, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
cartService.addToCart(userId, cartDTO);
|
||||
@@ -29,6 +40,13 @@ public class CartController {
|
||||
|
||||
@DeleteMapping("/remove/{productId}")
|
||||
@OperationGuard(action = "cart-remove", strategy = OperationGuardStrategy.NOOP_IF_DUPLICATE, ttlSeconds = 10)
|
||||
/**
|
||||
* Remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param productId parameter `productId` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> removeFromCart(@PathVariable Long productId, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
cartService.removeFromCart(userId, productId);
|
||||
@@ -37,6 +55,13 @@ public class CartController {
|
||||
|
||||
@PostMapping("/batch-remove")
|
||||
@OperationGuard(action = "cart-batch-remove", strategy = OperationGuardStrategy.NOOP_IF_DUPLICATE, ttlSeconds = 10)
|
||||
/**
|
||||
* Run business method `batchRemoveFromCart`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param cartItemIds parameter `cartItemIds` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> batchRemoveFromCart(@RequestBody List<Long> cartItemIds, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
cartService.batchRemoveFromCart(userId, cartItemIds);
|
||||
@@ -45,6 +70,13 @@ public class CartController {
|
||||
|
||||
@PutMapping("/update")
|
||||
@OperationGuard(action = "cart-update", ttlSeconds = 10, message = "购物车处理中,请勿重复操作")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param cartDTO parameter `cartDTO` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> updateCartQuantity(@RequestBody CartDTO cartDTO, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
cartService.updateCartQuantity(userId, cartDTO);
|
||||
@@ -52,6 +84,12 @@ public class CartController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<CartVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<CartVO>> getCartList(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
List<CartVO> cartList = cartService.getCartList(userId);
|
||||
@@ -60,6 +98,12 @@ public class CartController {
|
||||
|
||||
@DeleteMapping("/clear")
|
||||
@OperationGuard(action = "cart-clear", strategy = OperationGuardStrategy.NOOP_IF_DUPLICATE, ttlSeconds = 10)
|
||||
/**
|
||||
* Run business method `clearCart`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> clearCart(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
cartService.clearCart(userId);
|
||||
|
||||
+3
-1
@@ -21,7 +21,9 @@ import java.util.List;
|
||||
@RequestMapping({"/comment", "/api/comment"})
|
||||
@RequiredArgsConstructor
|
||||
public class CommentController {
|
||||
|
||||
/**
|
||||
* Variable `commentService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final CommentService commentService;
|
||||
|
||||
/**
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.service.ContactInfoService;
|
||||
import com.xiaowang.yuminailcore.vo.ContactInfoVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/contact-info", "/api/contact-info"})
|
||||
/**
|
||||
* ContactInfoController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class ContactInfoController {
|
||||
/**
|
||||
* Variable `contactInfoService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ContactInfoService contactInfoService;
|
||||
|
||||
@GetMapping("/shop/{shopId}/manager")
|
||||
/**
|
||||
* Run business method `shopManager`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param shopId parameter `shopId` supplied by the caller
|
||||
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ContactInfoVO> shopManager(HttpServletRequest request, @PathVariable Long shopId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(contactInfoService.getShopManagerContact(userId, shopId));
|
||||
}
|
||||
|
||||
@GetMapping("/product/{productId}/artist/{artistId}")
|
||||
/**
|
||||
* Run business method `productArtist`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param productId parameter `productId` supplied by the caller
|
||||
* @param artistId parameter `artistId` supplied by the caller
|
||||
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ContactInfoVO> productArtist(HttpServletRequest request, @PathVariable Long productId, @PathVariable Long artistId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(contactInfoService.getProductArtistContact(userId, productId, artistId));
|
||||
}
|
||||
|
||||
@GetMapping("/order/{orderId}/artist")
|
||||
public Result<ContactInfoVO> orderArtist(HttpServletRequest request, @PathVariable Long orderId, @RequestParam(required = false) Long artistId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(contactInfoService.getOrderArtistContact(userId, orderId, artistId));
|
||||
}
|
||||
|
||||
@GetMapping("/platform")
|
||||
/**
|
||||
* Run business method `platform`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ContactInfoVO> platform() {
|
||||
return Result.success(contactInfoService.getPlatformContact());
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -24,9 +24,17 @@ import java.util.List;
|
||||
@RequestMapping("/coupon")
|
||||
@RequiredArgsConstructor
|
||||
public class CouponController {
|
||||
|
||||
/**
|
||||
* Variable `couponService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final CouponService couponService;
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
/**
|
||||
|
||||
+71
-1
@@ -38,21 +38,60 @@ import java.util.stream.Collectors;
|
||||
@RestController
|
||||
@RequestMapping("/admin/dashboard")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* DashboardController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class DashboardController {
|
||||
|
||||
/**
|
||||
* Variable `userMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserMapper userMapper;
|
||||
/**
|
||||
* Variable `productMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ProductMapper productMapper;
|
||||
/**
|
||||
* Variable `shopMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopMapper shopMapper;
|
||||
/**
|
||||
* Variable `commentMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final CommentMapper commentMapper;
|
||||
/**
|
||||
* Variable `orderMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final OrderMapper orderMapper;
|
||||
/**
|
||||
* Variable `orderItemMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final OrderItemMapper orderItemMapper;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
/**
|
||||
* Variable `userShopBindingSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserShopBindingSupport userShopBindingSupport;
|
||||
/**
|
||||
* Variable `multiLevelCacheService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final MultiLevelCacheService multiLevelCacheService;
|
||||
/**
|
||||
* Variable `appCacheProperties`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AppCacheProperties appCacheProperties;
|
||||
|
||||
@GetMapping("/stats")
|
||||
@RequirePermission("dashboard:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<DashboardStatsVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<DashboardStatsVO> getDashboardStats(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopIdScope = resolveShopScope(currentUser);
|
||||
@@ -69,6 +108,13 @@ public class DashboardController {
|
||||
return Result.success(stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `buildDashboardStats`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param currentUser parameter `currentUser` supplied by the caller
|
||||
* @param shopIdScope parameter `shopIdScope` supplied by the caller
|
||||
* @return private DashboardStatsVO result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private DashboardStatsVO buildDashboardStats(UserDO currentUser, Long shopIdScope) {
|
||||
DashboardStatsVO stats = new DashboardStatsVO();
|
||||
|
||||
@@ -110,6 +156,12 @@ public class DashboardController {
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `resolveShopScope`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param currentUser parameter `currentUser` supplied by the caller
|
||||
* @return private Long result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private Long resolveShopScope(UserDO currentUser) {
|
||||
if (currentUser == null || currentUser.getType() == 4) {
|
||||
return null;
|
||||
@@ -117,6 +169,12 @@ public class DashboardController {
|
||||
return currentUser.getShopId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param shopId parameter `shopId` supplied by the caller
|
||||
* @return private Long result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private Long getTodayOrders(Long shopId) {
|
||||
// 获取今天的开始时间
|
||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
||||
@@ -133,6 +191,12 @@ public class DashboardController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param shopId parameter `shopId` supplied by the caller
|
||||
* @return private List<HotProductVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private List<HotProductVO> getHotProducts(Long shopId) {
|
||||
// 通过订单商品表统计每个商品的订单数量,按订单数量排序
|
||||
// 使用SQL查询获取商品及其订单数量
|
||||
@@ -180,6 +244,12 @@ public class DashboardController {
|
||||
return hotProducts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param shopId parameter `shopId` supplied by the caller
|
||||
* @return private List<RecentActivityVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private List<RecentActivityVO> getRecentActivities(Long shopId) {
|
||||
List<RecentActivityVO> activities = new ArrayList<>();
|
||||
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ import java.util.List;
|
||||
@RequestMapping({"/effect-diagram", "/api/effect-diagram"})
|
||||
@RequiredArgsConstructor
|
||||
public class EffectDiagramController {
|
||||
|
||||
/**
|
||||
* Variable `effectDiagramService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final EffectDiagramService effectDiagramService;
|
||||
|
||||
/**
|
||||
|
||||
+9
-1
@@ -19,9 +19,17 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/file")
|
||||
@RequiredArgsConstructor
|
||||
public class FrontendFileController {
|
||||
|
||||
/**
|
||||
* Variable `objectStorageFileService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
/**
|
||||
* Variable `minioService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final MinioService minioService;
|
||||
/**
|
||||
* Variable `objectStorageUrlSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
|
||||
/**
|
||||
|
||||
+32
-1
@@ -27,10 +27,21 @@ import java.util.Map;
|
||||
@RequestMapping("/health")
|
||||
@RequiredArgsConstructor
|
||||
public class HealthController {
|
||||
|
||||
/**
|
||||
* Variable `dataSource`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final DataSource dataSource;
|
||||
/**
|
||||
* Variable `stringRedisTemplate`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
/**
|
||||
* Variable `discoveryClient`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final DiscoveryClient discoveryClient;
|
||||
/**
|
||||
* Variable `environment`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final Environment environment;
|
||||
|
||||
/**
|
||||
@@ -42,6 +53,11 @@ public class HealthController {
|
||||
}
|
||||
|
||||
@GetMapping("/diagnostics")
|
||||
/**
|
||||
* Run business method `diagnostics`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<Map<String, Object>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Map<String, Object>> diagnostics() {
|
||||
Map<String, Object> diagnostics = new LinkedHashMap<>();
|
||||
diagnostics.put("service", environment.getProperty("spring.application.name", "yumi-nail-core"));
|
||||
@@ -52,6 +68,11 @@ public class HealthController {
|
||||
return Result.success(diagnostics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `checkDatabase`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return private Map<String, Object> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private Map<String, Object> checkDatabase() {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
@@ -65,6 +86,11 @@ public class HealthController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `checkRedis`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return private Map<String, Object> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private Map<String, Object> checkRedis() {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
try (RedisConnection connection = stringRedisTemplate.getConnectionFactory().getConnection()) {
|
||||
@@ -77,6 +103,11 @@ public class HealthController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `checkDiscovery`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return private Map<String, Object> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private Map<String, Object> checkDiscovery() {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
try {
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.LegalAgreementDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.LegalAgreementService;
|
||||
import com.xiaowang.yuminailcore.service.SecurityAuditLogService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.security.RequestThrottleService;
|
||||
import com.xiaowang.yuminailcore.vo.LegalAgreementVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserAgreementConsentVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/legal-agreement", "/api/legal-agreement"})
|
||||
public class LegalAgreementController {
|
||||
|
||||
private final LegalAgreementService legalAgreementService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditLogService securityAuditLogService;
|
||||
private final RequestThrottleService requestThrottleService;
|
||||
|
||||
@GetMapping("/current")
|
||||
public Result<List<LegalAgreementVO>> listCurrent(HttpServletRequest request) {
|
||||
requestThrottleService.checkAgreementRead(request, "ALL");
|
||||
return Result.success(legalAgreementService.listCurrentAgreements());
|
||||
}
|
||||
|
||||
@GetMapping("/current/{type}")
|
||||
public Result<LegalAgreementVO> getCurrent(HttpServletRequest request, @PathVariable String type) {
|
||||
requestThrottleService.checkAgreementRead(request, type);
|
||||
return Result.success(legalAgreementService.getCurrentAgreement(type));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/list")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
public Result<List<LegalAgreementVO>> listAdmin(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(legalAgreementService.listAdminAgreements(currentUser));
|
||||
}
|
||||
|
||||
@PostMapping("/admin/create")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "legal-agreement-create", ttlSeconds = 8, message = "协议保存处理中,请勿重复提交")
|
||||
public Result<Long> create(HttpServletRequest request, @Valid @RequestBody LegalAgreementDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long id = legalAgreementService.createAgreement(currentUser, dto);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_CREATE", "SUCCESS", dto.getAgreementType(), request);
|
||||
return Result.success(id);
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "legal-agreement-update", ttlSeconds = 8, message = "协议保存处理中,请勿重复提交")
|
||||
public Result<Boolean> update(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody LegalAgreementDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Boolean result = legalAgreementService.updateAgreement(currentUser, id, dto);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_UPDATE", "SUCCESS", String.valueOf(id), request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}/publish")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "legal-agreement-publish", ttlSeconds = 8, message = "协议发布处理中,请勿重复提交")
|
||||
public Result<Boolean> publish(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Boolean result = legalAgreementService.publishAgreement(currentUser, id);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_PUBLISH", "SUCCESS", String.valueOf(id), request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}/disable")
|
||||
@RequirePermission("legal_agreement:manage")
|
||||
@OperationGuard(action = "legal-agreement-disable", ttlSeconds = 8, message = "协议停用处理中,请勿重复提交")
|
||||
public Result<Boolean> disable(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Boolean result = legalAgreementService.disableAgreement(currentUser, id);
|
||||
securityAuditLogService.record(currentUser.getId(), currentUser.getAccount(), "LEGAL_AGREEMENT_DISABLE", "SUCCESS", String.valueOf(id), request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/user/agreement-consent/me")
|
||||
public Result<UserAgreementConsentVO> getMyConsent(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(legalAgreementService.getMyConsent(userId));
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -20,7 +20,9 @@ import java.util.List;
|
||||
@RequestMapping({"/login-identity", "/api/login-identity"})
|
||||
@RequiredArgsConstructor
|
||||
public class LoginIdentityController {
|
||||
|
||||
/**
|
||||
* Variable `loginIdentityService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final LoginIdentityService loginIdentityService;
|
||||
|
||||
/**
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.MessageHubPushConfigDTO;
|
||||
import com.xiaowang.yuminailcore.dto.MessageHubPushTestDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.MessageHubPushConfigService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.MessageHubPushConfigVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/messagehub-push-config", "/api/messagehub-push-config"})
|
||||
/**
|
||||
* MessageHubPushConfigController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class MessageHubPushConfigController {
|
||||
/**
|
||||
* Variable `configService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final MessageHubPushConfigService configService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/admin/list")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<MessageHubPushConfigVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<MessageHubPushConfigVO>> list(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.listConfigs(currentUser));
|
||||
}
|
||||
|
||||
@PostMapping("/admin/create")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
@OperationGuard(action = "messagehub-push-config-create", ttlSeconds = 8, message = "配置保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> create(HttpServletRequest request, @Valid @RequestBody MessageHubPushConfigDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.createConfig(currentUser, dto));
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
@OperationGuard(action = "messagehub-push-config-update", ttlSeconds = 8, message = "配置保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> update(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody MessageHubPushConfigDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.updateConfig(currentUser, id, dto));
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}/status")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
/**
|
||||
* Change the enabled/status flag of one record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param enabled parameter `enabled` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateStatus(HttpServletRequest request, @PathVariable Long id, @RequestParam Integer enabled) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.updateStatus(currentUser, id, enabled));
|
||||
}
|
||||
|
||||
@PostMapping("/admin/{id}/test")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
@OperationGuard(action = "messagehub-push-config-test", ttlSeconds = 8, message = "测试投递处理中,请勿重复提交")
|
||||
/**
|
||||
* Run a test call without changing normal business data.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> test(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody MessageHubPushTestDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.testConfig(currentUser, id, dto));
|
||||
}
|
||||
}
|
||||
+56
-1
@@ -11,6 +11,7 @@ import com.xiaowang.yuminailcore.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||
import com.xiaowang.yuminailcore.support.security.OperationGuardStrategy;
|
||||
import com.xiaowang.yuminailcore.support.security.UploadSecurityValidator;
|
||||
import com.xiaowang.yuminailcore.vo.ChunkUploadSessionVO;
|
||||
import com.xiaowang.yuminailcore.vo.ObjectStorageFileVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -39,18 +40,34 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
@Validated
|
||||
public class ObjectStorageFileController {
|
||||
|
||||
/**
|
||||
* Variable `objectStorageFileService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
/**
|
||||
* Variable `minioService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final MinioService minioService;
|
||||
/**
|
||||
* Variable `chunkUploadService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ChunkUploadService chunkUploadService;
|
||||
/**
|
||||
* Variable `objectStorageUrlSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
/**
|
||||
* Variable `snowflakeIdGenerator`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
private final UploadSecurityValidator uploadSecurityValidator;
|
||||
|
||||
@PostMapping("/upload/init")
|
||||
@OperationGuard(action = "admin-upload-init", ttlSeconds = 10, message = "上传处理中,请勿重复操作")
|
||||
public Result<ChunkUploadSessionVO> initChunkUpload(HttpServletRequest request,
|
||||
@Valid @RequestBody ChunkUploadInitRequestDTO requestDTO) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
uploadSecurityValidator.validateMetadata(requestDTO.getFileName(), requestDTO.getContentType(), requestDTO.getFileSize());
|
||||
return Result.success(chunkUploadService.initAdminObjectStorageUpload(userId, requestDTO));
|
||||
}
|
||||
|
||||
@@ -62,6 +79,7 @@ public class ObjectStorageFileController {
|
||||
@RequestParam("totalChunks") Integer totalChunks,
|
||||
@RequestParam("chunk") MultipartFile chunkFile) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
uploadSecurityValidator.validate(chunkFile);
|
||||
chunkUploadService.uploadAdminObjectStorageChunk(userId, uploadId, chunkIndex, totalChunks, chunkFile);
|
||||
return Result.success(true);
|
||||
}
|
||||
@@ -101,6 +119,13 @@ public class ObjectStorageFileController {
|
||||
|
||||
@DeleteMapping("/upload/{uploadId}")
|
||||
@OperationGuard(action = "admin-upload-cancel", ttlSeconds = 30, message = "上传处理中,请勿重复操作")
|
||||
/**
|
||||
* Run business method `cancelChunkUpload`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param uploadId parameter `uploadId` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> cancelChunkUpload(HttpServletRequest request, @PathVariable String uploadId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
chunkUploadService.clearAdminObjectStorageUpload(userId, uploadId);
|
||||
@@ -114,6 +139,7 @@ public class ObjectStorageFileController {
|
||||
@OperationGuard(action = "admin-upload-direct", ttlSeconds = 30, message = "上传处理中,请勿重复操作")
|
||||
public Result<ObjectStorageFileVO> uploadFile(@RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
uploadSecurityValidator.validate(file);
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String fileExtension = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
String objectName = snowflakeIdGenerator.nextIdString() + fileExtension;
|
||||
@@ -160,6 +186,12 @@ public class ObjectStorageFileController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@OperationGuard(action = "admin-file-create", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param objectStorageFileDTO parameter `objectStorageFileDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createObjectStorageFile(@RequestBody ObjectStorageFileDTO objectStorageFileDTO) {
|
||||
Long id = objectStorageFileService.createObjectStorageFile(objectStorageFileDTO);
|
||||
return Result.success(id);
|
||||
@@ -175,24 +207,47 @@ public class ObjectStorageFileController {
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@OperationGuard(action = "admin-file-delete", ttlSeconds = 10, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteObjectStorageFile(@PathVariable Long id) {
|
||||
boolean success = objectStorageFileService.deleteObjectStorageFile(id);
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<ObjectStorageFileVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ObjectStorageFileVO> getObjectStorageFileById(@PathVariable Long id) {
|
||||
ObjectStorageFileVO objectStorageFileVO = objectStorageFileService.getObjectStorageFileById(id);
|
||||
return Result.success(objectStorageFileVO);
|
||||
}
|
||||
|
||||
@GetMapping("/list/all")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<List<ObjectStorageFileVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ObjectStorageFileVO>> listAllObjectStorageFiles() {
|
||||
List<ObjectStorageFileVO> objectStorageFileVOs = objectStorageFileService.listAllObjectStorageFiles();
|
||||
return Result.success(objectStorageFileVOs);
|
||||
}
|
||||
|
||||
@GetMapping("/list/status/{status}")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param status parameter `status` supplied by the caller
|
||||
* @return Result<List<ObjectStorageFileVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ObjectStorageFileVO>> listObjectStorageFilesByStatus(@PathVariable Integer status) {
|
||||
List<ObjectStorageFileVO> objectStorageFileVOs = objectStorageFileService.listObjectStorageFilesByStatus(status);
|
||||
return Result.success(objectStorageFileVOs);
|
||||
|
||||
+117
-3
@@ -8,14 +8,20 @@ import com.xiaowang.yuminailcore.service.OrderService;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.vo.OrderVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserVO;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/order")
|
||||
/**
|
||||
* OrderController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class OrderController {
|
||||
|
||||
@Resource
|
||||
@@ -26,6 +32,13 @@ public class OrderController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@OperationGuard(action = "order-create", ttlSeconds = 15, message = "订单正在提交中,请勿重复点击")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param orderDTO parameter `orderDTO` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<OrderVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<OrderVO> createOrder(@RequestBody OrderDTO orderDTO, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
OrderVO orderVO = orderService.createOrder(userId, orderDTO);
|
||||
@@ -33,6 +46,12 @@ public class OrderController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<OrderVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<OrderVO>> getOrderList(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
List<OrderVO> orderList = orderService.getOrderList(userId);
|
||||
@@ -40,6 +59,13 @@ public class OrderController {
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{orderId}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param orderId parameter `orderId` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<OrderVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<OrderVO> getOrderDetail(@PathVariable Long orderId, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
OrderVO orderVO = orderService.getOrderDetail(orderId, userId);
|
||||
@@ -48,6 +74,13 @@ public class OrderController {
|
||||
|
||||
@PutMapping("/cancel/{orderId}")
|
||||
@OperationGuard(action = "order-cancel", ttlSeconds = 15, message = "操作进行中,请勿重复点击")
|
||||
/**
|
||||
* Run business method `cancelOrder`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param orderId parameter `orderId` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> cancelOrder(@PathVariable Long orderId, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
orderService.cancelOrder(orderId, userId);
|
||||
@@ -57,6 +90,12 @@ public class OrderController {
|
||||
// 后台管理接口
|
||||
@RequirePermission("order:view")
|
||||
@GetMapping("/admin/list")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<OrderVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<OrderVO>> getAllOrders(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Integer userType = (Integer) request.getAttribute("userType");
|
||||
@@ -69,6 +108,11 @@ public class OrderController {
|
||||
if (!Integer.valueOf(4).equals(userType) && !Integer.valueOf(3).equals(userType)) {
|
||||
UserVO currentUser = userService.getUserById(userId);
|
||||
if (currentUser == null || currentUser.getShopId() == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("当前账号未绑定店铺");
|
||||
}
|
||||
orderList = orderList.stream()
|
||||
@@ -81,11 +125,24 @@ public class OrderController {
|
||||
@RequirePermission("order:process")
|
||||
@PutMapping("/admin/process/{orderId}")
|
||||
@OperationGuard(action = "admin-order-process", ttlSeconds = 15, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Run business method `processOrder`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param orderId parameter `orderId` supplied by the caller
|
||||
* @param status parameter `status` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> processOrder(@PathVariable Long orderId, @RequestParam Integer status, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Integer userType = (Integer) request.getAttribute("userType");
|
||||
if (Integer.valueOf(3).equals(userType)) {
|
||||
if (!Integer.valueOf(2).equals(status)) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("美甲师只能完成属于自己的订单");
|
||||
}
|
||||
orderService.completeArtistOrder(orderId, userId);
|
||||
@@ -94,6 +151,11 @@ public class OrderController {
|
||||
if (!Integer.valueOf(4).equals(userType)) {
|
||||
UserVO currentUser = userService.getUserById(userId);
|
||||
if (currentUser == null || currentUser.getShopId() == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("当前账号未绑定店铺");
|
||||
}
|
||||
OrderVO orderVO = orderService.getAllOrders().stream()
|
||||
@@ -101,6 +163,11 @@ public class OrderController {
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (orderVO == null || !currentUser.getShopId().equals(orderVO.getShopId())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("无权处理其他店铺订单");
|
||||
}
|
||||
}
|
||||
@@ -111,23 +178,70 @@ public class OrderController {
|
||||
// 美甲师查看自己的订单
|
||||
@RequirePermission("order:view")
|
||||
@GetMapping("/artist/list")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<OrderVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<OrderVO>> getArtistOrders(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Integer userType = (Integer) request.getAttribute("userType");
|
||||
if (!Integer.valueOf(3).equals(userType)) {
|
||||
if (!Integer.valueOf(3).equals(userType) && !Integer.valueOf(2).equals(userType)) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("仅美甲师可查看自己的订单");
|
||||
}
|
||||
List<OrderVO> orderList = orderService.getOrdersByArtistId(userId);
|
||||
List<OrderVO> orderList = orderService.getArtistWorkbenchOrders(userId);
|
||||
return Result.success(orderList);
|
||||
}
|
||||
|
||||
@RequirePermission("order:view")
|
||||
@GetMapping("/artist/calendar/recent")
|
||||
// 调用示例:GET /order/artist/calendar/recent?days=7
|
||||
// 只返回当前登录美甲师/参与制作店长自己的预约,前端不用再做二次过滤。
|
||||
public Result<?> getArtistCalendarRecent(@RequestParam(value = "days", required = false) Integer days,
|
||||
HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Integer userType = (Integer) request.getAttribute("userType");
|
||||
return Result.success(orderService.getArtistCalendarRecent(userId, userType, days));
|
||||
}
|
||||
|
||||
@RequirePermission("order:view")
|
||||
@GetMapping("/artist/calendar/day")
|
||||
// 调用示例:GET /order/artist/calendar/day?date=2026-05-17
|
||||
// date 使用 yyyy-MM-dd,适合日历点选某一天后拉取详情。
|
||||
public Result<?> getArtistCalendarDay(@RequestParam("date")
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
|
||||
LocalDate date,
|
||||
HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Integer userType = (Integer) request.getAttribute("userType");
|
||||
return Result.success(orderService.getArtistCalendarDay(userId, userType, date));
|
||||
}
|
||||
|
||||
@RequirePermission("order:process")
|
||||
@PutMapping("/artist/complete/{orderId}")
|
||||
@OperationGuard(action = "artist-order-complete", ttlSeconds = 15, message = "操作处理中,请勿重复提交")
|
||||
/**
|
||||
* Complete a business action.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param orderId parameter `orderId` supplied by the caller
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<Void> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Void> completeArtistOrder(@PathVariable Long orderId, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Integer userType = (Integer) request.getAttribute("userType");
|
||||
if (!Integer.valueOf(3).equals(userType)) {
|
||||
if (!Integer.valueOf(3).equals(userType) && !Integer.valueOf(2).equals(userType)) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("仅美甲师可完成自己的订单");
|
||||
}
|
||||
orderService.completeArtistOrder(orderId, userId);
|
||||
|
||||
+19
-1
@@ -26,9 +26,17 @@ import java.util.List;
|
||||
@RequestMapping({"/permission", "/api/permission"})
|
||||
@RequiredArgsConstructor
|
||||
public class PermissionController {
|
||||
|
||||
/**
|
||||
* Variable `permissionService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final PermissionService permissionService;
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
/**
|
||||
@@ -128,6 +136,11 @@ public class PermissionController {
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
UserDO targetUser = userService.getById(userId);
|
||||
if (targetUser == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("目标用户不存在");
|
||||
}
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, "无权查看其他店铺用户权限");
|
||||
@@ -149,6 +162,11 @@ public class PermissionController {
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
UserDO targetUser = userService.getById(userPermissionDTO.getUserId());
|
||||
if (targetUser == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("目标用户不存在");
|
||||
}
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userPermissionDTO.getUserId(), "无权给其他店铺用户分配权限");
|
||||
|
||||
+55
-1
@@ -17,13 +17,29 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/product")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* ProductController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class ProductController {
|
||||
|
||||
/**
|
||||
* Variable `productService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ProductService productService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("product:create")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param productDTO parameter `productDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createProduct(HttpServletRequest request, @RequestBody ProductDTO productDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
productDTO.setShopId(adminScopeHelper.resolveShopScope(currentUser, productDTO.getShopId()));
|
||||
@@ -33,6 +49,14 @@ public class ProductController {
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission("product:edit")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param productDTO parameter `productDTO` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateProduct(HttpServletRequest request, @PathVariable Long id, @RequestBody ProductDTO productDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
ProductVO productVO = productService.getProductById(id);
|
||||
@@ -48,6 +72,13 @@ public class ProductController {
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("product:delete")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteProduct(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
ProductVO productVO = productService.getProductById(id);
|
||||
@@ -60,24 +91,47 @@ public class ProductController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<ProductVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ProductVO> getProductById(@PathVariable Long id) {
|
||||
ProductVO productVO = productService.getProductById(id);
|
||||
return Result.success(productVO);
|
||||
}
|
||||
|
||||
@GetMapping("/list/all")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<List<ProductVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ProductVO>> listAllProducts() {
|
||||
List<ProductVO> productVOs = productService.listAllProducts();
|
||||
return Result.success(productVOs);
|
||||
}
|
||||
|
||||
@GetMapping("/list/shop/{shopId}")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param shopId parameter `shopId` supplied by the caller
|
||||
* @return Result<List<ProductVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ProductVO>> listProductsByShopId(@PathVariable Long shopId) {
|
||||
List<ProductVO> productVOs = productService.listProductsByShopId(shopId);
|
||||
return Result.success(productVOs);
|
||||
}
|
||||
|
||||
@GetMapping("/list/tag/{tag}")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param tag parameter `tag` supplied by the caller
|
||||
* @return Result<List<ProductVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ProductVO>> listProductsByTag(@PathVariable String tag) {
|
||||
List<ProductVO> productVOs = productService.listProductsByTag(tag);
|
||||
return Result.success(productVOs);
|
||||
|
||||
+3
-1
@@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping("/product-like")
|
||||
@RequiredArgsConstructor
|
||||
public class ProductLikeController {
|
||||
|
||||
/**
|
||||
* Variable `productLikeService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ProductLikeService productLikeService;
|
||||
|
||||
/**
|
||||
|
||||
+71
-1
@@ -19,13 +19,29 @@ import java.util.stream.Collectors;
|
||||
@RestController
|
||||
@RequestMapping("/shop")
|
||||
@RequiredArgsConstructor
|
||||
/**
|
||||
* ShopController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class ShopController {
|
||||
|
||||
/**
|
||||
* Variable `shopService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopService shopService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@PostMapping("/create")
|
||||
@RequirePermission("shop:create")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param shopDTO parameter `shopDTO` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> createShop(HttpServletRequest request, @RequestBody ShopDTO shopDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "鍙湁骞冲彴绠$悊鍛樺彲浠ュ垱寤哄簵閾?");
|
||||
@@ -35,6 +51,14 @@ public class ShopController {
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission("shop:edit")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param shopDTO parameter `shopDTO` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateShop(HttpServletRequest request, @PathVariable Long id, @RequestBody ShopDTO shopDTO) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
ShopVO shopVO = shopService.getShopById(id);
|
||||
@@ -42,12 +66,22 @@ public class ShopController {
|
||||
return Result.success(false);
|
||||
}
|
||||
adminScopeHelper.ensureShopAccessible(currentUser, shopVO.getId(), "无权编辑其他店铺信息");
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
shopDTO.setAuthorizationExpireTime(shopVO.getAuthorizationExpireTime());
|
||||
}
|
||||
boolean success = shopService.updateShop(id, shopDTO);
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission("shop:delete")
|
||||
/**
|
||||
* Delete, revoke, or logically remove a record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> deleteShop(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "鍙湁骞冲彴绠$悊鍛樺彲浠ュ垹闄ゅ簵閾?");
|
||||
@@ -57,6 +91,14 @@ public class ShopController {
|
||||
|
||||
@PutMapping("/status/{id}")
|
||||
@RequirePermission("shop:edit")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param statusRequest parameter `statusRequest` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateShopStatus(HttpServletRequest request, @PathVariable Long id, @RequestBody StatusRequest statusRequest) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "只有平台管理员可以启停店铺");
|
||||
@@ -65,6 +107,12 @@ public class ShopController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<ShopVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ShopVO> getShopById(@PathVariable Long id) {
|
||||
ShopVO shopVO = shopService.getShopById(id);
|
||||
return Result.success(shopVO);
|
||||
@@ -72,6 +120,12 @@ public class ShopController {
|
||||
|
||||
@GetMapping("/list/all")
|
||||
@RequirePermission("shop:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<ShopVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ShopVO>> listAllShops(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
List<ShopVO> shopVOs;
|
||||
@@ -85,12 +139,23 @@ public class ShopController {
|
||||
}
|
||||
|
||||
@GetMapping("/list/shopName/{shopName}")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param shopName parameter `shopName` supplied by the caller
|
||||
* @return Result<List<ShopVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ShopVO>> listShopsByShopName(@PathVariable String shopName) {
|
||||
List<ShopVO> shopVOs = shopService.listShopsByShopName(shopName);
|
||||
return Result.success(shopVOs);
|
||||
}
|
||||
|
||||
@GetMapping("/list/simple")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<List<ShopSimpleVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ShopSimpleVO>> listShopsSimple() {
|
||||
List<ShopVO> shopVOs = shopService.listAllShops();
|
||||
List<ShopSimpleVO> simpleVOs = shopVOs.stream()
|
||||
@@ -100,6 +165,11 @@ public class ShopController {
|
||||
}
|
||||
|
||||
@GetMapping("/list/public")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return Result<List<ShopVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ShopVO>> listPublicShops() {
|
||||
return Result.success(shopService.listAllShops());
|
||||
}
|
||||
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.SystemMessageCreateDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.SystemMessageService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.MessageTargetOptionsVO;
|
||||
import com.xiaowang.yuminailcore.vo.MessageUnreadCountVO;
|
||||
import com.xiaowang.yuminailcore.vo.SystemMessageVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/system-message", "/api/system-message"})
|
||||
/**
|
||||
* SystemMessageController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class SystemMessageController {
|
||||
/**
|
||||
* Variable `systemMessageService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final SystemMessageService systemMessageService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@PostMapping("/admin/create")
|
||||
@RequirePermission("message:create")
|
||||
@OperationGuard(action = "system-message-create", ttlSeconds = 8, message = "消息发布处理中,请勿重复提交")
|
||||
/**
|
||||
* Run business method `publish`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> publish(HttpServletRequest request, @Valid @RequestBody SystemMessageCreateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(systemMessageService.publishMessage(currentUser, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/list")
|
||||
@RequirePermission("message:view")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<SystemMessageVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<SystemMessageVO>> listAdminMessages(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(systemMessageService.listAdminMessages(currentUser));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/{id}")
|
||||
@RequirePermission("message:view")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<SystemMessageVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<SystemMessageVO> getAdminMessage(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(systemMessageService.getAdminMessage(currentUser, id));
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}/revoke")
|
||||
@RequirePermission("message:delete")
|
||||
@OperationGuard(action = "system-message-revoke", ttlSeconds = 8, message = "消息撤回处理中,请勿重复操作")
|
||||
/**
|
||||
* Run business method `revoke`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> revoke(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(systemMessageService.revokeMessage(currentUser, id));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/target-options")
|
||||
@RequirePermission("message:create")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<MessageTargetOptionsVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<MessageTargetOptionsVO> listTargetOptions(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(systemMessageService.listTargetOptions(currentUser));
|
||||
}
|
||||
|
||||
@GetMapping("/my/list")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<SystemMessageVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<SystemMessageVO>> listMyMessages(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(systemMessageService.listMyMessages(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/my/popup")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<SystemMessageVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<SystemMessageVO>> listMyPopupMessages(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(systemMessageService.listMyPopupMessages(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/my/unread-count")
|
||||
/**
|
||||
* Run business method `countMyUnreadMessages`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<MessageUnreadCountVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<MessageUnreadCountVO> countMyUnreadMessages(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(new MessageUnreadCountVO(systemMessageService.countMyUnreadMessages(userId)));
|
||||
}
|
||||
|
||||
@GetMapping("/my/{id}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<SystemMessageVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<SystemMessageVO> getMyMessage(HttpServletRequest request, @PathVariable Long id) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(systemMessageService.getMyMessage(userId, id));
|
||||
}
|
||||
|
||||
@PutMapping("/my/{id}/popup-shown")
|
||||
/**
|
||||
* Mark user state such as read or popup shown.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> markPopupShown(HttpServletRequest request, @PathVariable Long id) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(systemMessageService.markPopupShown(userId, id));
|
||||
}
|
||||
|
||||
@PutMapping("/my/{id}/read")
|
||||
/**
|
||||
* Mark user state such as read or popup shown.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> markRead(HttpServletRequest request, @PathVariable Long id) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(systemMessageService.markRead(userId, id));
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.SystemParameterConfigDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.SystemParameterConfigService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.SystemParameterConfigVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/system-parameter-config", "/api/system-parameter-config"})
|
||||
public class SystemParameterConfigController {
|
||||
|
||||
private final SystemParameterConfigService configService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/admin/list")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
public Result<List<SystemParameterConfigVO>> list(HttpServletRequest request,
|
||||
@RequestParam(required = false) String configGroup) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.listConfigs(currentUser, configGroup));
|
||||
}
|
||||
|
||||
@PostMapping("/admin/save")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
@OperationGuard(action = "system-parameter-config-save", ttlSeconds = 8, message = "系统参数保存处理中,请勿重复提交")
|
||||
public Result<Boolean> save(HttpServletRequest request, @Valid @RequestBody SystemParameterConfigDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(configService.saveConfig(currentUser, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/admin/tencent-map")
|
||||
@RequirePermission("messagehub:config:manage")
|
||||
public Result<Map<String, String>> getTencentMapKey(HttpServletRequest request) {
|
||||
adminScopeHelper.getCurrentUser(request);
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("key", configService.getEnabledValue("MAP", "TENCENT_MAP_KEY"));
|
||||
return Result.success(result);
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,13 @@ import java.util.List;
|
||||
@RequestMapping("/tag")
|
||||
@RequiredArgsConstructor
|
||||
public class TagController {
|
||||
|
||||
/**
|
||||
* Variable `tagService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final TagService tagService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
/**
|
||||
|
||||
+307
-13
@@ -11,12 +11,20 @@ import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.ChunkUploadSessionVO;
|
||||
import com.xiaowang.yuminailcore.vo.LoginShopSelectionVO;
|
||||
import com.xiaowang.yuminailcore.vo.LoginResponseVO;
|
||||
import com.xiaowang.yuminailcore.vo.BalanceChangeDetailVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserAssetVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserRelationVO;
|
||||
import com.xiaowang.yuminailcore.vo.UserVO;
|
||||
import com.xiaowang.yuminailcore.vo.InviteCodeVO;
|
||||
import com.xiaowang.yuminailcore.vo.WechatMiniLoginResultVO;
|
||||
import com.xiaowang.yuminailcore.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.service.UserAssetService;
|
||||
import com.xiaowang.yuminailcore.service.UserService;
|
||||
import com.xiaowang.yuminailcore.service.ShopRoleService;
|
||||
import com.xiaowang.yuminailcore.service.VerificationCodeService;
|
||||
import com.xiaowang.yuminailcore.service.WechatMiniAuthService;
|
||||
import com.xiaowang.yuminailcore.service.LegalAgreementService;
|
||||
import com.xiaowang.yuminailcore.service.SecurityAuditLogService;
|
||||
import com.xiaowang.yuminailcore.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||
import com.xiaowang.yuminailcore.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.support.security.RequestThrottleService;
|
||||
@@ -44,17 +52,56 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/user")
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
/**
|
||||
* Variable `userService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserService userService;
|
||||
/**
|
||||
* Variable `userAssetService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserAssetService userAssetService;
|
||||
/**
|
||||
* Variable `minioService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final MinioService minioService;
|
||||
/**
|
||||
* Variable `chunkUploadService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ChunkUploadService chunkUploadService;
|
||||
/**
|
||||
* Variable `verificationCodeService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final VerificationCodeService verificationCodeService;
|
||||
/**
|
||||
* Variable `userMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserMapper userMapper;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
/**
|
||||
* Variable `shopRoleService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ShopRoleService shopRoleService;
|
||||
/**
|
||||
* Variable `snowflakeIdGenerator`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
/**
|
||||
* Variable `wechatMiniAuthService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final WechatMiniAuthService wechatMiniAuthService;
|
||||
/**
|
||||
* Variable `objectStorageUrlSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
/**
|
||||
* Variable `requestThrottleService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final RequestThrottleService requestThrottleService;
|
||||
private final LegalAgreementService legalAgreementService;
|
||||
private final SecurityAuditLogService securityAuditLogService;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
@@ -115,6 +162,11 @@ public class UserController {
|
||||
adminScopeHelper.requirePlatformAdmin(currentUser, "仅系统管理员可以删除用户");
|
||||
UserVO targetUser = requireAccessibleUser(currentUser, id, "无权删除其他店铺用户");
|
||||
if (Integer.valueOf(4).equals(targetUser.getType())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("管理员账号不允许删除");
|
||||
}
|
||||
boolean success = userService.deleteUser(id);
|
||||
@@ -124,17 +176,53 @@ public class UserController {
|
||||
@PutMapping("/unbind/{id}")
|
||||
@RequirePermission("user:unbind")
|
||||
@OperationGuard(action = "admin-user-unbind", ttlSeconds = 10, message = "操作进行中,请勿重复点击")
|
||||
/**
|
||||
* Run business method `unbindUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> unbindUser(HttpServletRequest request, @PathVariable Long id) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
UserVO targetUser = requireAccessibleUser(currentUser, id, "无权解绑其他店铺用户");
|
||||
adminScopeHelper.ensureAssignableUserType(currentUser, targetUser.getType());
|
||||
if (Integer.valueOf(4).equals(targetUser.getType())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("管理员账号不允许解绑");
|
||||
}
|
||||
boolean success = userService.unbindUserInShopWithOperator(id, currentUser.getShopId(), currentUser.getType());
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@GetMapping("/asset/me")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<UserAssetVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<UserAssetVO> getMyAsset(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(userAssetService.getUserAsset(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/balance/history/me")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<BalanceChangeDetailVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<BalanceChangeDetailVO>> getMyBalanceHistory(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(userAssetService.listBalanceHistory(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询用户
|
||||
*
|
||||
@@ -188,6 +276,11 @@ public class UserController {
|
||||
@GetMapping("/list/type/{type}")
|
||||
public Result<List<UserVO>> listUsersByType(@PathVariable Integer type) {
|
||||
if (!Integer.valueOf(3).equals(type)) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("仅支持查询可预约的美甲师列表");
|
||||
}
|
||||
List<UserVO> userVOs = userService.listUsersByType(type).stream()
|
||||
@@ -215,6 +308,12 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/check/account/{account}")
|
||||
/**
|
||||
* Run business method `checkAccountAvailability`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param account parameter `account` supplied by the caller
|
||||
* @return Result<AvailabilityVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<AvailabilityVO> checkAccountAvailability(@PathVariable String account) {
|
||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
||||
UserDO userDO = userMapper.selectOne(
|
||||
@@ -227,6 +326,12 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/check/login-account/{account}")
|
||||
/**
|
||||
* Run business method `checkLoginAccountAvailability`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param account parameter `account` supplied by the caller
|
||||
* @return Result<LoginAccountAvailabilityVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginAccountAvailabilityVO> checkLoginAccountAvailability(@PathVariable String account) {
|
||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
||||
UserDO userDO = userMapper.selectOne(
|
||||
@@ -244,16 +349,34 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/check/login-shops/account/{account}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param account parameter `account` supplied by the caller
|
||||
* @return Result<LoginShopSelectionVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginShopSelectionVO> getLoginShopsByAccount(@PathVariable String account) {
|
||||
return Result.success(userService.getLoginShopSelectionByAccount(AccountValidationUtils.requireValidAccount(account)));
|
||||
}
|
||||
|
||||
@GetMapping("/check/login-shops/phone/{phone}")
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param phone parameter `phone` supplied by the caller
|
||||
* @return Result<LoginShopSelectionVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginShopSelectionVO> getLoginShopsByPhone(@PathVariable String phone) {
|
||||
return Result.success(userService.getLoginShopSelectionByPhone(phone));
|
||||
}
|
||||
|
||||
@GetMapping("/check/phone/{phone}")
|
||||
/**
|
||||
* Run business method `checkPhoneAvailability`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param phone parameter `phone` supplied by the caller
|
||||
* @return Result<AvailabilityVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<AvailabilityVO> checkPhoneAvailability(@PathVariable String phone) {
|
||||
UserDO userDO = userMapper.selectOne(
|
||||
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
||||
@@ -275,8 +398,18 @@ public class UserController {
|
||||
@OperationGuard(action = "user-login", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
public Result<LoginResponseVO> login(HttpServletRequest request, @Valid @RequestBody LoginRequestDTO loginRequestDTO) {
|
||||
requestThrottleService.checkLogin(request, loginRequestDTO.getAccount());
|
||||
LoginResponseVO loginResponseVO = userService.login(loginRequestDTO);
|
||||
return Result.success(loginResponseVO);
|
||||
legalAgreementService.requireAccepted(loginRequestDTO);
|
||||
try {
|
||||
LoginResponseVO loginResponseVO = userService.login(loginRequestDTO);
|
||||
legalAgreementService.recordConsent(loginResponseVO.getUserInfo().getId(), loginRequestDTO, "USER_PASSWORD_LOGIN", request);
|
||||
requestThrottleService.clearLoginFailure(request, loginRequestDTO.getAccount());
|
||||
securityAuditLogService.record(loginResponseVO.getUserInfo().getId(), loginRequestDTO.getAccount(), "USER_LOGIN", "SUCCESS", null, request);
|
||||
return Result.success(loginResponseVO);
|
||||
} catch (RuntimeException exception) {
|
||||
requestThrottleService.recordLoginFailure(request, loginRequestDTO.getAccount());
|
||||
securityAuditLogService.record(null, loginRequestDTO.getAccount(), "USER_LOGIN", "FAIL", exception.getMessage(), request);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,30 +422,73 @@ public class UserController {
|
||||
@OperationGuard(action = "user-phone-login", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
public Result<LoginResponseVO> phoneLogin(HttpServletRequest request, @RequestBody PhoneLoginRequestDTO phoneLoginRequestDTO) {
|
||||
requestThrottleService.checkLogin(request, phoneLoginRequestDTO.getPhone());
|
||||
LoginResponseVO loginResponseVO = userService.phoneLogin(phoneLoginRequestDTO);
|
||||
return Result.success(loginResponseVO);
|
||||
legalAgreementService.requireAccepted(phoneLoginRequestDTO);
|
||||
try {
|
||||
LoginResponseVO loginResponseVO = userService.phoneLogin(phoneLoginRequestDTO);
|
||||
legalAgreementService.recordConsent(loginResponseVO.getUserInfo().getId(), phoneLoginRequestDTO, "USER_PHONE_LOGIN", request);
|
||||
requestThrottleService.clearLoginFailure(request, phoneLoginRequestDTO.getPhone());
|
||||
securityAuditLogService.record(loginResponseVO.getUserInfo().getId(), phoneLoginRequestDTO.getPhone(), "USER_PHONE_LOGIN", "SUCCESS", null, request);
|
||||
return Result.success(loginResponseVO);
|
||||
} catch (RuntimeException exception) {
|
||||
requestThrottleService.recordLoginFailure(request, phoneLoginRequestDTO.getPhone());
|
||||
securityAuditLogService.record(null, phoneLoginRequestDTO.getPhone(), "USER_PHONE_LOGIN", "FAIL", exception.getMessage(), request);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/wechat-mini/auto-login")
|
||||
@OperationGuard(action = "wechat-mini-auto-login", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
/**
|
||||
* Run business method `wechatMiniAutoLogin`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param requestDTO parameter `requestDTO` supplied by the caller
|
||||
* @return Result<WechatMiniLoginResultVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<WechatMiniLoginResultVO> wechatMiniAutoLogin(@Valid @RequestBody WechatMiniAutoLoginRequestDTO requestDTO) {
|
||||
return Result.success(wechatMiniAuthService.autoLogin(requestDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/wechat-mini/phone-login")
|
||||
@OperationGuard(action = "wechat-mini-phone-login", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
public Result<WechatMiniLoginResultVO> wechatMiniPhoneLogin(@Valid @RequestBody WechatMiniPhoneLoginRequestDTO requestDTO) {
|
||||
return Result.success(wechatMiniAuthService.phoneLogin(requestDTO));
|
||||
/**
|
||||
* Run business method `wechatMiniPhoneLogin`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param requestDTO parameter `requestDTO` supplied by the caller
|
||||
* @return Result<WechatMiniLoginResultVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<WechatMiniLoginResultVO> wechatMiniPhoneLogin(HttpServletRequest request, @Valid @RequestBody WechatMiniPhoneLoginRequestDTO requestDTO) {
|
||||
requestThrottleService.checkWechatMiniLogin(request, "wechat-mini-phone");
|
||||
legalAgreementService.requireAccepted(requestDTO);
|
||||
WechatMiniLoginResultVO result = wechatMiniAuthService.phoneLogin(requestDTO);
|
||||
recordWechatConsentIfLoggedIn(result, requestDTO, "WECHAT_MINI_PHONE_LOGIN", request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("/wechat-mini/confirm-login")
|
||||
@OperationGuard(action = "wechat-mini-confirm-login", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
public Result<WechatMiniLoginResultVO> confirmWechatMiniLogin(@Valid @RequestBody WechatMiniConfirmLoginRequestDTO requestDTO) {
|
||||
return Result.success(wechatMiniAuthService.confirmLogin(requestDTO));
|
||||
/**
|
||||
* Run business method `confirmWechatMiniLogin`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param requestDTO parameter `requestDTO` supplied by the caller
|
||||
* @return Result<WechatMiniLoginResultVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<WechatMiniLoginResultVO> confirmWechatMiniLogin(HttpServletRequest request, @Valid @RequestBody WechatMiniConfirmLoginRequestDTO requestDTO) {
|
||||
requestThrottleService.checkWechatMiniLogin(request, requestDTO.getTicket());
|
||||
legalAgreementService.requireAccepted(requestDTO);
|
||||
WechatMiniLoginResultVO result = wechatMiniAuthService.confirmLogin(requestDTO);
|
||||
recordWechatConsentIfLoggedIn(result, requestDTO, "WECHAT_MINI_CONFIRM_LOGIN", request);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("/switch-shop")
|
||||
@OperationGuard(action = "user-switch-shop", ttlSeconds = 10, message = "门店切换中,请勿重复操作")
|
||||
/**
|
||||
* Run business method `switchShop`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param switchShopRequestDTO parameter `switchShopRequestDTO` supplied by the caller
|
||||
* @return Result<LoginResponseVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<LoginResponseVO> switchShop(HttpServletRequest request, @RequestBody SwitchShopRequestDTO switchShopRequestDTO) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(userService.switchShop(userId, switchShopRequestDTO.getShopId(), (String) request.getAttribute("sessionId")));
|
||||
@@ -326,9 +502,49 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
@OperationGuard(action = "user-register", ttlSeconds = 8, message = "登录处理中,请勿重复提交")
|
||||
public Result<Boolean> register(@Valid @RequestBody RegisterRequestDTO registerRequestDTO) {
|
||||
boolean success = userService.register(registerRequestDTO);
|
||||
return Result.success(success);
|
||||
public Result<Boolean> register(HttpServletRequest request, @Valid @RequestBody RegisterRequestDTO registerRequestDTO) {
|
||||
requestThrottleService.checkRegister(request, registerRequestDTO.getAccount());
|
||||
legalAgreementService.requireAccepted(registerRequestDTO);
|
||||
try {
|
||||
boolean success = userService.register(registerRequestDTO);
|
||||
UserDO userDO = userMapper.selectOne(
|
||||
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
||||
.eq(UserDO::getAccount, AccountValidationUtils.requireValidAccount(registerRequestDTO.getAccount()))
|
||||
.eq(UserDO::getIsDelete, 0)
|
||||
.last("limit 1")
|
||||
);
|
||||
if (userDO != null) {
|
||||
legalAgreementService.recordConsent(userDO.getId(), registerRequestDTO, "USER_REGISTER", request);
|
||||
securityAuditLogService.record(userDO.getId(), userDO.getAccount(), "USER_REGISTER", "SUCCESS", null, request);
|
||||
}
|
||||
return Result.success(success);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditLogService.record(null, registerRequestDTO.getAccount(), "USER_REGISTER", "FAIL", exception.getMessage(), request);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/relation/me")
|
||||
/**
|
||||
* Run business method `relationMe`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<UserRelationVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<UserRelationVO> relationMe(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(userService.getCurrentUserRelation(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/invite-code/resolve")
|
||||
/**
|
||||
* Run business method `resolveInviteCode`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param code parameter `code` supplied by the caller
|
||||
* @return Result<InviteCodeVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<InviteCodeVO> resolveInviteCode(@RequestParam String code) {
|
||||
return Result.success(shopRoleService.resolveInviteCode(code));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,9 +558,15 @@ public class UserController {
|
||||
public Result<Boolean> sendVerificationCode(HttpServletRequest request, @RequestBody SendVerificationCodeRequestDTO sendVerificationCodeRequestDTO) {
|
||||
requestThrottleService.checkSendCode(request, sendVerificationCodeRequestDTO.getPhone());
|
||||
if (!verificationCodeService.canResend(sendVerificationCodeRequestDTO.getPhone())) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param 1 parameter `1` supplied by the caller
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("验证码发送过于频繁,请1分钟后再试");
|
||||
}
|
||||
verificationCodeService.sendVerificationCode(sendVerificationCodeRequestDTO.getPhone());
|
||||
verificationCodeService.sendVerificationCode(sendVerificationCodeRequestDTO.getPhone(), sendVerificationCodeRequestDTO.getSceneCode());
|
||||
return Result.success(true);
|
||||
}
|
||||
|
||||
@@ -359,6 +581,7 @@ public class UserController {
|
||||
public Result<Boolean> resetPasswordByPhone(HttpServletRequest request, @RequestBody ResetPasswordRequestDTO resetPasswordRequestDTO) {
|
||||
requestThrottleService.checkResetPassword(request, resetPasswordRequestDTO.getPhone());
|
||||
boolean success = userService.resetPasswordByPhone(resetPasswordRequestDTO);
|
||||
securityAuditLogService.record(null, resetPasswordRequestDTO.getPhone(), "RESET_PASSWORD_BY_PHONE", success ? "SUCCESS" : "FAIL", null, request);
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@@ -386,6 +609,22 @@ public class UserController {
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
@GetMapping("/agreement-consent/me")
|
||||
public Result<com.xiaowang.yuminailcore.vo.UserAgreementConsentVO> getMyAgreementConsent(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(legalAgreementService.getMyConsent(userId));
|
||||
}
|
||||
|
||||
private void recordWechatConsentIfLoggedIn(WechatMiniLoginResultVO result,
|
||||
com.xiaowang.yuminailcore.dto.AgreementAwareRequest dto,
|
||||
String entry,
|
||||
HttpServletRequest request) {
|
||||
if (result != null && result.getUserInfo() != null) {
|
||||
legalAgreementService.recordConsent(result.getUserInfo().getId(), dto, entry, request);
|
||||
securityAuditLogService.record(result.getUserInfo().getId(), null, entry, "SUCCESS", null, request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*
|
||||
@@ -467,6 +706,13 @@ public class UserController {
|
||||
|
||||
@PostMapping("/upload-avatar/complete")
|
||||
@OperationGuard(action = "user-avatar-upload-complete", ttlSeconds = 30, message = "上传处理中,请勿重复操作")
|
||||
/**
|
||||
* Complete a business action.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param requestDTO parameter `requestDTO` supplied by the caller
|
||||
* @return Result<String> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<String> completeAvatarUpload(HttpServletRequest request, @Valid @RequestBody ChunkUploadCompleteRequestDTO requestDTO) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
try (ChunkUploadService.PreparedUploadFile preparedUploadFile =
|
||||
@@ -488,6 +734,13 @@ public class UserController {
|
||||
|
||||
@DeleteMapping("/upload-avatar/{uploadId}")
|
||||
@OperationGuard(action = "user-avatar-upload-cancel", ttlSeconds = 30, message = "上传处理中,请勿重复操作")
|
||||
/**
|
||||
* Run business method `cancelAvatarUpload`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param uploadId parameter `uploadId` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> cancelAvatarUpload(HttpServletRequest request, @PathVariable String uploadId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
chunkUploadService.clearUserAvatarUpload(userId, uploadId);
|
||||
@@ -524,6 +777,13 @@ public class UserController {
|
||||
@OperationGuard(action = "admin-user-reset-password", ttlSeconds = 10, message = "操作进行中,请勿重复点击")
|
||||
public Result<Boolean> resetPassword(HttpServletRequest request, @PathVariable Long userId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
/**
|
||||
* Run business method `requireAccessibleUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param currentUser parameter `currentUser` supplied by the caller
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @return result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
requireAccessibleUser(currentUser, userId, "无权重置其他店铺用户密码");
|
||||
Long currentUserId = (Long) request.getAttribute("userId");
|
||||
boolean success = userService.resetPassword(userId, currentUserId);
|
||||
@@ -586,15 +846,34 @@ public class UserController {
|
||||
return Result.success(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `requireAccessibleUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param currentUser parameter `currentUser` supplied by the caller
|
||||
* @param userId parameter `userId` supplied by the caller
|
||||
* @param message parameter `message` supplied by the caller
|
||||
* @return private UserVO result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private UserVO requireAccessibleUser(UserDO currentUser, Long userId, String message) {
|
||||
UserVO targetUser = userService.getUserById(userId);
|
||||
if (targetUser == null) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @return throw new result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
throw new RuntimeException("目标用户不存在");
|
||||
}
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, message);
|
||||
return targetUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `sanitizePublicArtist`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param userVO parameter `userVO` supplied by the caller
|
||||
* @return private UserVO result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private UserVO sanitizePublicArtist(UserVO userVO) {
|
||||
UserVO sanitized = new UserVO();
|
||||
sanitized.setId(userVO.getId());
|
||||
@@ -619,14 +898,29 @@ public class UserController {
|
||||
|
||||
@Data
|
||||
public static class AvailabilityVO {
|
||||
/**
|
||||
* Variable `available`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final boolean available;
|
||||
/**
|
||||
* Variable `message`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final String message;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class LoginAccountAvailabilityVO {
|
||||
/**
|
||||
* Variable `exists`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final boolean exists;
|
||||
/**
|
||||
* Variable `nickname`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final String nickname;
|
||||
/**
|
||||
* Variable `message`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final String message;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ import java.util.List;
|
||||
@RequestMapping({"/vip-benefit", "/api/vip-benefit"})
|
||||
@RequiredArgsConstructor
|
||||
public class VipBenefitController {
|
||||
|
||||
/**
|
||||
* Variable `vipBenefitService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final VipBenefitService vipBenefitService;
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ import java.util.List;
|
||||
@RequestMapping({"/vip-info", "/api/vip-info"})
|
||||
@RequiredArgsConstructor
|
||||
public class VipInfoController {
|
||||
|
||||
/**
|
||||
* Variable `vipInfoService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final VipInfoService vipInfoService;
|
||||
|
||||
/**
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.VipRechargePlanDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.VipRechargePlanService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.VipRechargePlanVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping({"/vip-recharge-plan", "/api/vip-recharge-plan"})
|
||||
/**
|
||||
* VipRechargePlanController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class VipRechargePlanController {
|
||||
/**
|
||||
* Variable `vipRechargePlanService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final VipRechargePlanService vipRechargePlanService;
|
||||
/**
|
||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@GetMapping("/admin/list")
|
||||
@RequirePermission("user:vip:manage")
|
||||
public Result<List<VipRechargePlanVO>> listAdmin(HttpServletRequest request, @RequestParam(required = false) Long shopId) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(vipRechargePlanService.listAdminPlans(currentUser, shopId));
|
||||
}
|
||||
|
||||
@PostMapping("/admin/create")
|
||||
@RequirePermission("user:vip:manage")
|
||||
@OperationGuard(action = "vip-recharge-plan-create", ttlSeconds = 8, message = "充值档位保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Create a new record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Long> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Long> create(HttpServletRequest request, @Valid @RequestBody VipRechargePlanDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(vipRechargePlanService.createPlan(currentUser, dto));
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}")
|
||||
@RequirePermission("user:vip:manage")
|
||||
@OperationGuard(action = "vip-recharge-plan-update", ttlSeconds = 8, message = "充值档位保存处理中,请勿重复提交")
|
||||
/**
|
||||
* Update an existing record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param dto parameter `dto` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> update(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody VipRechargePlanDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(vipRechargePlanService.updatePlan(currentUser, id, dto));
|
||||
}
|
||||
|
||||
@PutMapping("/admin/{id}/status")
|
||||
@RequirePermission("user:vip:manage")
|
||||
/**
|
||||
* Change the enabled/status flag of one record.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @param id parameter `id` supplied by the caller
|
||||
* @param status parameter `status` supplied by the caller
|
||||
* @return Result<Boolean> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<Boolean> updateStatus(HttpServletRequest request, @PathVariable Long id, @RequestParam Integer status) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(vipRechargePlanService.updateStatus(currentUser, id, status));
|
||||
}
|
||||
|
||||
@GetMapping("/my/list")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
* @param request parameter `request` supplied by the caller
|
||||
* @return Result<List<VipRechargePlanVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<VipRechargePlanVO>> listMy(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(vipRechargePlanService.listMyPlans(userId));
|
||||
}
|
||||
}
|
||||
+4
@@ -13,6 +13,10 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wishlist")
|
||||
/**
|
||||
* WishlistController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
||||
*/
|
||||
public class WishlistController {
|
||||
|
||||
@Autowired
|
||||
|
||||
+19
@@ -5,15 +5,34 @@ import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
/**
|
||||
* AdminUserBalanceChangeDTO is a request DTO. Controllers receive it from JSON body or query parameters and pass it into services.
|
||||
* Field and parameter names are kept consistent with the frontend/API payload to make tracing easier.
|
||||
*/
|
||||
public class AdminUserBalanceChangeDTO {
|
||||
|
||||
/**
|
||||
* Field `amount` (BigDecimal): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* Field `changeScene` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private String changeScene;
|
||||
|
||||
/**
|
||||
* Field `relatedOrderId` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private Long relatedOrderId;
|
||||
|
||||
/**
|
||||
* Field `externalOrderNo` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private String externalOrderNo;
|
||||
|
||||
/**
|
||||
* Field `remark` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user