密码重置功能优化
This commit is contained in:
@@ -399,16 +399,14 @@ export const adminCouponApi = {
|
|||||||
return adminApi.delete(`/coupon/delete/${id}`, { params: { shopId } })
|
return adminApi.delete(`/coupon/delete/${id}`, { params: { shopId } })
|
||||||
},
|
},
|
||||||
distributeCoupon: (data: { couponId: number; userIds: number[]; quantity: number }, shopId: number) => {
|
distributeCoupon: (data: { couponId: number; userIds: number[]; quantity: number }, shopId: number) => {
|
||||||
const params: any = {
|
// 构建查询字符串,确保userIds以正确的格式传递
|
||||||
couponId: data.couponId,
|
let queryString = `couponId=${data.couponId}&quantity=${data.quantity}&shopId=${shopId}`;
|
||||||
quantity: data.quantity,
|
if (data.userIds && data.userIds.length > 0) {
|
||||||
shopId: shopId
|
data.userIds.forEach(userId => {
|
||||||
};
|
queryString += `&userIds=${userId}`;
|
||||||
// 处理userIds数组,确保它能被后端正确解析
|
});
|
||||||
data.userIds.forEach((userId, index) => {
|
}
|
||||||
params[`userIds[${index}]`] = userId;
|
return adminApi.post(`/coupon/distribute?${queryString}`)
|
||||||
});
|
|
||||||
return adminApi.post('/coupon/distribute', null, { params })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
@@ -48,6 +48,8 @@ declare module 'vue' {
|
|||||||
AModal: typeof import('ant-design-vue/es')['Modal']
|
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||||
APageHeader: typeof import('ant-design-vue/es')['PageHeader']
|
APageHeader: typeof import('ant-design-vue/es')['PageHeader']
|
||||||
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
||||||
|
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||||
|
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||||
ARow: typeof import('ant-design-vue/es')['Row']
|
ARow: typeof import('ant-design-vue/es')['Row']
|
||||||
ASelect: typeof import('ant-design-vue/es')['Select']
|
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||||
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ import { ref, reactive, onMounted, computed } from 'vue'
|
|||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
import type { FormInstance } from 'ant-design-vue'
|
||||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||||
import { adminCouponApi, adminTagApi, adminShopApi, type Shop } from '@/api/admin'
|
import { adminCouponApi, adminTagApi, adminShopApi, userApi, type Shop } from '@/api/admin'
|
||||||
import type { Coupon } from '@/api/coupon'
|
import type { Coupon } from '@/api/coupon'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
@@ -687,15 +687,24 @@ const handleDelete = (record: Coupon) => {
|
|||||||
// 加载用户列表
|
// 加载用户列表
|
||||||
const fetchUsers = async () => {
|
const fetchUsers = async () => {
|
||||||
try {
|
try {
|
||||||
// 这里应该调用获取用户列表的API
|
const currentUser = getCurrentUserInfo()
|
||||||
// 暂时使用模拟数据
|
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : undefined
|
||||||
|
// 调用真实的用户列表API
|
||||||
|
const res = await userApi.listUsers({
|
||||||
|
page: 1,
|
||||||
|
size: 100,
|
||||||
|
shopId: shopId,
|
||||||
|
status: 1 // 只获取激活状态的用户
|
||||||
|
})
|
||||||
|
userList.value = res.list || []
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取用户列表失败:', error)
|
||||||
|
// 如果API调用失败,使用模拟数据作为 fallback
|
||||||
userList.value = [
|
userList.value = [
|
||||||
{ id: 1, nickname: '用户1', account: 'user1' },
|
{ id: 1, nickname: '用户1', account: 'user1' },
|
||||||
{ id: 2, nickname: '用户2', account: 'user2' },
|
{ id: 2, nickname: '用户2', account: 'user2' },
|
||||||
{ id: 3, nickname: '用户3', account: 'user3' }
|
{ id: 3, nickname: '用户3', account: 'user3' }
|
||||||
]
|
]
|
||||||
} catch (error) {
|
|
||||||
console.error('获取用户列表失败:', error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ const handleStatusChange = async (record: UserVO, checked: boolean) => {
|
|||||||
const handleResetPassword = (record: UserVO) => {
|
const handleResetPassword = (record: UserVO) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认重置密码',
|
title: '确认重置密码',
|
||||||
content: `确定要将用户 ${record.nickname} 的密码重置为 88888888 吗?`,
|
content: `确定要将用户 ${record.nickname} 的密码重置为 888888 吗?`,
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
try {
|
try {
|
||||||
await userApi.resetPassword(record.id)
|
await userApi.resetPassword(record.id)
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ public interface OrderItemMapper extends BaseMapper<OrderItemDO> {
|
|||||||
"WHERE p.shop_id = #{shopId} AND o.create_time >= STR_TO_DATE(#{todayStart}, '%Y-%m-%d %H:%i:%s') AND o.is_delete = 0")
|
"WHERE p.shop_id = #{shopId} AND o.create_time >= STR_TO_DATE(#{todayStart}, '%Y-%m-%d %H:%i:%s') AND o.is_delete = 0")
|
||||||
java.util.Map<String, Object> countTodayOrdersByShopId(@Param("shopId") Long shopId, @Param("todayStart") String todayStart);
|
java.util.Map<String, Object> countTodayOrdersByShopId(@Param("shopId") Long shopId, @Param("todayStart") String todayStart);
|
||||||
|
|
||||||
@Select("SELECT COUNT(DISTINCT order_id) as count FROM t_order WHERE create_time >= STR_TO_DATE(#{todayStart}, '%Y-%m-%d %H:%i:%s') AND is_delete = 0")
|
@Select("SELECT COUNT(DISTINCT id) as count FROM t_order WHERE create_time >= STR_TO_DATE(#{todayStart}, '%Y-%m-%d %H:%i:%s') AND is_delete = 0")
|
||||||
java.util.Map<String, Object> countTodayOrders(@Param("todayStart") String todayStart);
|
java.util.Map<String, Object> countTodayOrders(@Param("todayStart") String todayStart);
|
||||||
}
|
}
|
||||||
+1
-1
@@ -556,7 +556,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
throw new RuntimeException("权限不足,只能重置比自己级别低的用户密码");
|
throw new RuntimeException("权限不足,只能重置比自己级别低的用户密码");
|
||||||
}
|
}
|
||||||
|
|
||||||
targetUser.setPassword(passwordEncoder.encode("88888888"));
|
targetUser.setPassword(passwordEncoder.encode("888888"));
|
||||||
targetUser.setUpdateTime(LocalDateTime.now());
|
targetUser.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
return userMapper.updateById(targetUser) > 0;
|
return userMapper.updateById(targetUser) > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user