diff --git a/src/api/companyAddress.js b/src/api/companyAddress.js index a046ad2..ce41988 100644 --- a/src/api/companyAddress.js +++ b/src/api/companyAddress.js @@ -1,7 +1,27 @@ +// 导入封装好的请求工具,用于发起HTTP请求 import request from '@/utils/request' + +/** + * fetchList - 获取公司地址列表数据的函数 + * + * 该函数通过发送一个 GET 请求到指定的后端接口, + * 以获取公司地址列表数据。数据返回后,可以用于前端页面渲染。 + * + * @returns {Promise} - 返回一个Promise对象,包含接口返回的数据 + * + * 用法示例: + * fetchList().then(response => { + * console.log(response); // 处理接口返回的数据 + * }).catch(error => { + * console.error(error); // 处理错误 + * }); + */ export function fetchList() { return request({ - url:'/companyAddress/list', - method:'get' + // 接口的URL路径,指向公司地址列表的后端接口 + url: '/companyAddress/list', + + // 请求方法:使用 HTTP GET 方法获取数据 + method: 'get' }) } diff --git a/src/api/coupon.js b/src/api/coupon.js index 7253ea7..fdfacbf 100644 --- a/src/api/coupon.js +++ b/src/api/coupon.js @@ -1,38 +1,106 @@ +// 导入封装的 HTTP 请求工具,用于与后端接口通信 import request from '@/utils/request' + +/** + * fetchList - 获取优惠券列表 + * + * 该函数通过 GET 请求获取优惠券列表,并支持通过参数进行查询筛选。 + * + * @param {Object} params - 查询参数,例如分页、筛选条件等。 + * @returns {Promise} - 返回一个Promise对象,包含接口返回的数据 + * + * 用法示例: + * fetchList({ pageNum: 1, pageSize: 10 }).then(response => { + * console.log(response); + * }); + */ export function fetchList(params) { return request({ - url:'/coupon/list', - method:'get', - params:params + url: '/coupon/list', // 接口URL路径:获取优惠券列表 + method: 'get', // 请求方法:GET + params: params // 查询参数,通过URL参数传递 }) } +/** + * createCoupon - 创建新的优惠券 + * + * 该函数通过 POST 请求向后端提交新优惠券的数据。 + * + * @param {Object} data - 优惠券的详细数据,包含名称、折扣等字段。 + * @returns {Promise} - 返回一个Promise对象,包含接口返回的数据 + * + * 用法示例: + * createCoupon({ name: 'Spring Sale', discount: 20 }).then(response => { + * console.log(response); + * }); + */ export function createCoupon(data) { return request({ - url:'/coupon/create', - method:'post', - data:data + url: '/coupon/create', // 接口URL路径:创建优惠券 + method: 'post', // 请求方法:POST + data: data // 请求体,包含优惠券数据 }) } +/** + * getCoupon - 获取单个优惠券的详情 + * + * 该函数通过 GET 请求获取指定ID的优惠券详细信息。 + * + * @param {number|string} id - 优惠券的唯一标识ID。 + * @returns {Promise} - 返回一个Promise对象,包含优惠券的详细数据 + * + * 用法示例: + * getCoupon(1).then(response => { + * console.log(response); + * }); + */ export function getCoupon(id) { return request({ - url:'/coupon/'+id, - method:'get', + url: '/coupon/' + id, // 接口URL路径:根据ID获取优惠券详情 + method: 'get' // 请求方法:GET }) } -export function updateCoupon(id,data) { +/** + * updateCoupon - 更新指定优惠券的信息 + * + * 该函数通过 POST 请求提交修改后的优惠券数据,更新指定ID的优惠券。 + * + * @param {number|string} id - 优惠券的唯一标识ID。 + * @param {Object} data - 修改后的优惠券数据。 + * @returns {Promise} - 返回一个Promise对象,包含操作结果 + * + * 用法示例: + * updateCoupon(1, { name: 'Updated Sale', discount: 25 }).then(response => { + * console.log(response); + * }); + */ +export function updateCoupon(id, data) { return request({ - url:'/coupon/update/'+id, - method:'post', - data:data + url: '/coupon/update/' + id, // 接口URL路径:更新指定ID的优惠券 + method: 'post', // 请求方法:POST + data: data // 请求体,包含修改后的数据 }) } +/** + * deleteCoupon - 删除指定优惠券 + * + * 该函数通过 POST 请求删除指定ID的优惠券。 + * + * @param {number|string} id - 优惠券的唯一标识ID。 + * @returns {Promise} - 返回一个Promise对象,包含操作结果 + * + * 用法示例: + * deleteCoupon(1).then(response => { + * console.log(response); + * }); + */ export function deleteCoupon(id) { return request({ - url:'/coupon/delete/'+id, - method:'post', + url: '/coupon/delete/' + id, // 接口URL路径:删除指定ID的优惠券 + method: 'post' // 请求方法:POST }) } diff --git a/src/api/couponHistory.js b/src/api/couponHistory.js index 278a410..1a498b1 100644 --- a/src/api/couponHistory.js +++ b/src/api/couponHistory.js @@ -1,8 +1,27 @@ +// 导入封装的 HTTP 请求工具,用于发送 HTTP 请求 import request from '@/utils/request' + +/** + * fetchList - 获取优惠券历史记录列表 + * + * 该函数通过 GET 请求获取优惠券使用历史的记录列表。 + * 可以通过传入查询参数(如分页、筛选条件等)来筛选数据。 + * + * @param {Object} params - 查询参数,包括分页信息、筛选条件等。 + * 示例参数:{ pageNum: 1, pageSize: 10, couponId: 1001 } + * @returns {Promise} - 返回一个 Promise 对象,包含接口返回的数据。 + * + * 用法示例: + * fetchList({ pageNum: 1, pageSize: 10 }).then(response => { + * console.log(response); // 处理接口返回的数据 + * }).catch(error => { + * console.error('获取数据失败:', error); // 处理请求错误 + * }); + */ export function fetchList(params) { return request({ - url:'/couponHistory/list', - method:'get', - params:params + url: '/couponHistory/list', // 接口URL路径:获取优惠券历史记录列表 + method: 'get', // 请求方法:GET + params: params // 查询参数,通过 URL 参数传递 }) } diff --git a/src/api/flash.js b/src/api/flash.js index 52d499d..17685bc 100644 --- a/src/api/flash.js +++ b/src/api/flash.js @@ -1,35 +1,109 @@ +// 导入封装的 HTTP 请求工具,用于发送 HTTP 请求 import request from '@/utils/request' + +/** + * fetchList - 获取限时购活动列表 + * + * 该函数通过 GET 请求获取限时购活动的列表数据,并支持通过参数进行查询筛选。 + * + * @param {Object} params - 查询参数,例如分页、筛选条件等。 + * 示例:{ pageNum: 1, pageSize: 10 } + * @returns {Promise} - 返回一个 Promise 对象,包含接口返回的数据 + * + * 用法示例: + * fetchList({ pageNum: 1, pageSize: 10 }).then(response => { + * console.log(response); + * }); + */ export function fetchList(params) { return request({ - url:'/flash/list', - method:'get', - params:params + url: '/flash/list', // 接口URL:获取限时购活动列表 + method: 'get', // 请求方法:GET + params: params // 查询参数,通过 URL 查询字符串传递 }) } -export function updateStatus(id,params) { + +/** + * updateStatus - 更新限时购活动状态 + * + * 该函数通过 POST 请求更新指定限时购活动的状态。 + * + * @param {number|string} id - 限时购活动的唯一标识ID + * @param {Object} params - 状态更新参数,例如 { status: 1 } + * @returns {Promise} - 返回一个 Promise 对象,包含操作结果 + * + * 用法示例: + * updateStatus(1, { status: 1 }).then(response => { + * console.log(response); + * }); + */ +export function updateStatus(id, params) { return request({ - url:'/flash/update/status/'+id, - method:'post', - params:params + url: '/flash/update/status/' + id, // 接口URL:更新指定活动状态 + method: 'post', // 请求方法:POST + params: params // 状态参数,通过 URL 查询字符串传递 }) } + +/** + * deleteFlash - 删除指定的限时购活动 + * + * 该函数通过 POST 请求删除指定ID的限时购活动。 + * + * @param {number|string} id - 限时购活动的唯一标识ID + * @returns {Promise} - 返回一个 Promise 对象,包含操作结果 + * + * 用法示例: + * deleteFlash(1).then(response => { + * console.log(response); + * }); + */ export function deleteFlash(id) { return request({ - url:'/flash/delete/'+id, - method:'post' + url: '/flash/delete/' + id, // 接口URL:删除指定活动 + method: 'post' // 请求方法:POST }) } + +/** + * createFlash - 创建新的限时购活动 + * + * 该函数通过 POST 请求向后端提交新的限时购活动数据。 + * + * @param {Object} data - 活动的详细数据,例如 { name: 'Flash Sale', startTime: '2024-06-01' } + * @returns {Promise} - 返回一个 Promise 对象,包含创建结果 + * + * 用法示例: + * createFlash({ name: 'Summer Flash Sale', startTime: '2024-06-01' }).then(response => { + * console.log(response); + * }); + */ export function createFlash(data) { return request({ - url:'/flash/create', - method:'post', - data:data + url: '/flash/create', // 接口URL:创建限时购活动 + method: 'post', // 请求方法:POST + data: data // 请求体,包含活动的详细数据 }) } -export function updateFlash(id,data) { + +/** + * updateFlash - 更新指定的限时购活动 + * + * 该函数通过 POST 请求提交更新后的活动数据,更新指定ID的限时购活动。 + * + * @param {number|string} id - 限时购活动的唯一标识ID + * @param {Object} data - 更新后的活动数据 + * @returns {Promise} - 返回一个 Promise 对象,包含操作结果 + * + * 用法示例: + * updateFlash(1, { name: 'Updated Flash Sale', startTime: '2024-06-15' }).then(response => { + * console.log(response); + * }); + */ +export function updateFlash(id, data) { return request({ - url:'/flash/update/'+id, - method:'post', - data:data + url: '/flash/update/' + id, // 接口URL:更新指定ID的活动 + method: 'post', // 请求方法:POST + data: data // 请求体,包含更新后的活动数据 }) } diff --git a/src/api/flashProductRelation.js b/src/api/flashProductRelation.js index 0e739d5..199dd9d 100644 --- a/src/api/flashProductRelation.js +++ b/src/api/flashProductRelation.js @@ -1,28 +1,88 @@ +// 导入封装的 HTTP 请求工具,用于与后端 API 进行通信 import request from '@/utils/request' + +/** + * fetchList - 获取限时购商品关联列表 + * + * 该函数通过 GET 请求获取限时购活动与商品的关联列表, + * 支持通过查询参数进行筛选和分页。 + * + * @param {Object} params - 查询参数,例如分页和过滤条件。 + * 示例:{ flashId: 1, pageNum: 1, pageSize: 10 } + * @returns {Promise} - 返回一个 Promise 对象,包含接口返回的数据。 + * + * 用法示例: + * fetchList({ flashId: 1, pageNum: 1, pageSize: 10 }).then(response => { + * console.log(response); + * }); + */ export function fetchList(params) { return request({ - url:'/flashProductRelation/list', - method:'get', - params:params + url: '/flashProductRelation/list', // 接口URL:获取关联列表 + method: 'get', // 请求方法:GET + params: params // 查询参数,通过 URL 传递 }) } + +/** + * createFlashProductRelation - 创建新的限时购商品关联 + * + * 该函数通过 POST 请求提交限时购活动与商品的关联数据。 + * + * @param {Object} data - 关联数据,例如 { flashId: 1, productId: 100, sort: 1 } + * @returns {Promise} - 返回一个 Promise 对象,包含操作结果。 + * + * 用法示例: + * createFlashProductRelation({ flashId: 1, productId: 100, sort: 1 }).then(response => { + * console.log(response); + * }); + */ export function createFlashProductRelation(data) { return request({ - url:'/flashProductRelation/create', - method:'post', - data:data + url: '/flashProductRelation/create', // 接口URL:创建关联 + method: 'post', // 请求方法:POST + data: data // 请求体,包含关联数据 }) } + +/** + * deleteFlashProductRelation - 删除指定的限时购商品关联 + * + * 该函数通过 POST 请求删除指定 ID 的限时购商品关联数据。 + * + * @param {number|string} id - 限时购商品关联的唯一标识 ID。 + * @returns {Promise} - 返回一个 Promise 对象,包含操作结果。 + * + * 用法示例: + * deleteFlashProductRelation(1).then(response => { + * console.log(response); + * }); + */ export function deleteFlashProductRelation(id) { return request({ - url:'/flashProductRelation/delete/'+id, - method:'post' + url: '/flashProductRelation/delete/' + id, // 接口URL:删除关联 + method: 'post' // 请求方法:POST }) } -export function updateFlashProductRelation(id,data) { + +/** + * updateFlashProductRelation - 更新指定的限时购商品关联数据 + * + * 该函数通过 POST 请求提交更新后的限时购商品关联数据。 + * + * @param {number|string} id - 限时购商品关联的唯一标识 ID。 + * @param {Object} data - 更新后的关联数据,例如 { sort: 2 } + * @returns {Promise} - 返回一个 Promise 对象,包含操作结果。 + * + * 用法示例: + * updateFlashProductRelation(1, { sort: 2 }).then(response => { + * console.log(response); + * }); + */ +export function updateFlashProductRelation(id, data) { return request({ - url:'/flashProductRelation/update/'+id, - method:'post', - data:data + url: '/flashProductRelation/update/' + id, // 接口URL:更新关联 + method: 'post', // 请求方法:POST + data: data // 请求体,包含更新数据 }) }